Searching Java™ Archive (JAR) files for a class or a list of classes

Technote (FAQ)
Problem
How to search for a class or retrieve a list of classes contained in a JAR file.
Solution
You can search through JAR files in two different ways. When executed using the steps below, both methods will put the list of all .class files into a list.out file.
  1. Enter the following lines within a script file on a Unix® server. Do this in the directory containing the JAR files:

    for i in `ls *.jar`
    do
    jar -tvf $i > list.out 2>&1
    done

  2. You can also enter the following method at a Unix command prompt. Make sure that this is run while in the directory containing the JAR files:

    find . -name "*.jar" -exec jar -tvf {} \; > list.out 2>&1

    The JAR command writes its output to stderr and therefore you must put it to a file. Otherwise it scrolls by on the screen.

Finally, in order to find a specific class, you can either edit the file or enter the following at a Unix command prompt:

cat list.out | grep DummyKeyring











Document Information

Product categories: Software, Application Servers, Distributed Application & Web Servers, WebSphere Application Server, Java SDK
Operating system(s): AIX, Linux, Multi-Platform
Software version: 3.5, 4.0, 5.0, 5.1, 6.0
Software edition: Standard, Advanced, Enterprise
Reference #: 1023498
IBM Group: Software Group
Modified date: 2004-03-03