Dependency Walker for Java? [closed]
-
29-09-2019 - |
Question
I am looking for a tool that lists the .class dependencies for a given Java class to run. Kind of like what Dependency Walker does for Windows applications.
I am aware of some tools, but they are overly complicated or not quite a match, including
Any suggestions? TIA!!
Solution
The JVM will only load classes that are actually referenced in the program. Therefore, you will probably not be able to reduce runtime memory consumption by pruning the dependencies. If you are after reducing program size to ease deployment though, you can use this to detect which classes are actually needed: Simply run the application with the VM's class loading logging enabled, and the logfile will list all used classes.
For instance, for the Sun JVM, you would add the VM parameter -verbose:class
, i.e. launch your application as follows:
java -verbose:class -cp thejarfiles package.Main password
and postprocess the log to extract all class names.
(Of course this approach assumes the same classes are used for each execution of the program, which is probably the case for your "simple CLI utility")
OTHER TIPS
Although you already accepted an answer, I'd like to contribute that you might want to take a look at CodePro AnalytiX - an Eclipse plugin allowing for code analysis including dependency analysis.