Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to analyse which jar file is used in a Java program?

Tags:

java

classpath

Suppose there is a jar file named callme.jar

and it's located in several directories,

how to analyse which one of them is used at run-time?

like image 471
omg Avatar asked Jun 04 '09 13:06

omg


People also ask

How do I analyze a JAR file?

If the JAR file contains compiled . class files, I would suggest JD-Gui. Type that on Google. That what I use everyday to have an overlook at methods signature and public functions etc..!

How can I tell which JAR file is compiled?

Download a hex editor and open one of the class files inside the JAR and look at byte offsets 4 through 7. The version information is built in. Note: As mentioned in the comment below, those bytes tell you what version the class has been compiled FOR, not what version compiled it.

How do I find the Java JAR file?

It is often located in the "Program Files\Java" or "Program Files (x86)\Java" folder, within a possible subfolder below the Java folder. Once you find the file, select it and click OK.

Can you check the code of JAR file?

Jar files are archive files that contains of a lot of different java classes (files). You can use winzip/winrar to open the jar files and you can see those java classes in jar files. Typically you can use a Java decompiler to decompile the class file and look into the source code.


1 Answers

Invoke the java executable with the -verbose:class argument. This will produce output like:

[Loaded org.apache.log4j.helpers.ThreadLocalMap from file:/C:/.../1.2.14/log4j-1.2.14.jar]
[Loaded org.apache.commons.cli.Option from file:/C:/.../commons-cli-1.2.jar]

like image 170
matt b Avatar answered Sep 22 '22 14:09

matt b