What Classes the JVM is Loading From Where

One of the most common deployment problems in Java occurs when there are multiple jar files in mulitple lib directories, and it's so difficult to figure out where the Java Class Loader got what versions of certain classes. This is especially true, for example, when Jrun is loading its own classes from jrun.jar, pre-empting newer classes from jars that are in the classpath.

There is a simple way to find out what classes the JVM is loading, and from what directory the classes are being loaded. If you want to find out whehter a class was loaded and from where, search from the list of loaded classes and it will tell you.

You ask for this list of loaded classes by adding the following java.arg when you start Java:

java -verbose:class

Don't forget the - sign before the word verbose (the parm is -verbose:class).

Here is a sample of some output that is put in the out.log:

[Loaded java.net.Socket from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]
[Loaded java.net.SocketAddress from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]
[Loaded java.net.InetSocketAddress from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]
[Loaded java.net.SocketOptions from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]
[Loaded java.net.SocketImpl from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]
[Loaded java.net.PlainSocketImpl from /xenv/java/sun4/5.x/1.4.1_02/jre/lib/rt.jar]

The log is very long, so don't run an application with this java.args parm except to get information about the loading of classes.

Other verbose parameters are:

java -verbose:gc

This tells you more information about Java garbage collection.

java -verbose:jni

Tells more about activity involving Java Native Interface.