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

Technote (troubleshooting)


Problem(Abstract)

How to search for a class or retrieve a list of classes contained in a Java™ Archive (JAR) file.

Resolving the problem

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

Cross reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

WebSphere Application Server
Java SDK

Software version:

6.0, 6.1, 7.0, 8.0, 8.5

Operating system(s):

AIX, Linux

Software edition:

Advanced, Enterprise, Standard

Reference #:

1023498

Modified date:

2013-03-22

Translate my page

Machine Translation

Content navigation