Other Languages on the JVM Village

Love Jython? Can't get enough JRuby? Groovy? Dynamic languages on the JVM can set you free! Scala? Sure! Let us know what you think here in the Other Languages on the JVM SIG

Using scala scripts to check Java jar files

Here I attached two scripts that might help you working with jar files.

Have you tried to verify that a Class must exists in a lib directory that has few dozens jar files? For example I read from a forum that there is a ServerInfo.properties inside one of tomcat jar, so I run this:
$ scala searchjar.scala ServerInfo /opt/tomcat6/lib
/opt/tomcat6/lib/catalina.jar org/apache/catalina/util/ServerInfo.class
/opt/tomcat6/lib/catalina.jar org/apache/catalina/util/ServerInfo.properties
The script can walk over one or more directory and search all jar files for you.

The second thing I do once a while is I want to see the content of a text inside the jar. For the example above, I can run my second script like this:
$ scala displayjar.scala /opt/tomcat6/lib/catalina.jar org/apache/catalina/util/ServerInfo.properties
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

server.info=Apache Tomcat/6.0.18
server.number=6.0.18.0
server.built=Jul 22 2008 02:00:36
You can even run the displayjar.scala with just a jar file, and it default to print out the Manifest file content.

Hope these scripts are useful to you.