tags:

views:

31

answers:

2

Hi ,

I have a jar file and I want to know which all classes are within it. Is there any way I can do that?

+1  A: 

A jar file is just a fancy zip archive. You can use the classes in the java.util.jar package to read a jar file and traverse its contents, looking for .class files.

vanza
+2  A: 

How about using jar

jar tf jar-file
  • The t option indicates that you want to view the table of contents of the JAR file.
  • The f option indicates that the JAR file whose contents are to be viewed is specified on the command line. Without the f option, the Jar tool would expect a filename on stdin.
  • The jar-file argument is the filename (or path and filename) of the JAR file whose contents you want to view.

and if you want to list just the .class files you can filter the result using grep as:

jar tf jar-file | grep '\.class$'
codaddict
Thanks! It worked.
TopCoder