views:

352

answers:

4

I have a third-party jar file that comes with the javadocs for only part of the API. Is there a way to reverse engineer the jar file to obtain a complete listing of classes and methods?

+4  A: 

jar tf will list the contents for you. javap will allow you to see more details of the classes (see the tools guide).

However, are you sure you want to be using these unpublished APIs? It's usually a really bad idea.

Tom Hawtin - tackline
+1  A: 

If you're using eclipse, you can just add it to a project's classpath and explore it using the treeview and/or content assist.

I'd assume other IDEs can do similar.

From a command-line point of view, you can unjar it (jar xf foo.jar) and use javap against all files.

Scott Stanchfield
+2  A: 

As Scott said, you can use Eclipse to get a lot of what you're looking for.

I would recommend getting the JadClipse plugin which will decompile the .class files on the fly and show you actual Java code as you browse the classes in the IDE.

Mike Deck
Agree. A very powerful combination.
Thorbjørn Ravn Andersen
+1  A: 
  • Eclipse would work great

  • A Java Decompiler would translate the classes back into some semblence of source code that you could study to learn about the classes, the methods, their signatures, and maybe even some insight into valid values for some arguments (e.g. don't pass a null for this argument or you'll trigger a NullPointerException immediately). But roll up your sleeves to unjar the jar and run the decompiler against all the class files. This is essentially what Eclipse is doing for help text with undocumented classes.

  • Finally, of course, a "real programmer" would read the byte-code directly without need for a decompiler.

Bert F