How to get names of classes inside a jar file?

sticksu picture sticksu · Mar 30, 2013 · Viewed 133.6k times · Source

I have a JAR file and I need to get the name of all classes inside this JAR file. How can I do that?

I googled it and saw something about JarFile or Java ClassLoader but I have no idea how to do it.

Answer

Sanjeev Gupta picture Sanjeev Gupta · Mar 30, 2013

You can use Java jar tool. List the content of jar file in a txt file and you can see all the classes in the jar.

jar tvf jarfile.jar

-t list table of contents for archive

-v generate verbose output on standard output

-f specify archive file name