How to find which jars and in what order are loaded by a classloader?

Marina picture Marina · Feb 1, 2010 · Viewed 55.4k times · Source

I could not find a clear answer to this question elsewhere, so I'll try here:

Is there some way (programmatic or other) to get a list of JARs/classes loaded by an Application Classloader in the precise order they were loaded? By Application Classloader I mean the classloader that loads an EAR application in an applications server (WLS, WAS, JBoss...), but obviously, it applies to any classloader.

So, to generalize, what I would like to find out is the list and order of JARs loaded by a specified classloader. Not individual classes, that is easy enough to find out by calling the classloader.getPackages(), but a list of JAR files that were loaded by this classloader.

Answer

Steve picture Steve · Feb 23, 2010

Have you tried to use the JVM option -verbose:class. It displays all loaded JAR files and classes.

Example:

[Opened C:\Program Files\JDK160~1\jre\lib\rt.jar]
[Loaded java.lang.Object from C:\Program Files\JDK160~1\jre\lib\rt.jar]