Tuesday, January 04, 2011

Where did the class get loaded from?

As with most enterprise apps gone crazy you have a bunch of duplicate jars or some jars at places you don't even know were in the classpath. And once a while you need to know from which jar a particular class file was loaded. To find this out run java with the -verbose:class flag. For each class loaded, the VM will print out the folder or jar where the class was found.

~ $ java -verbose:class HelloWorld
[Loaded HelloWorld from file:/C:/work/cygwin/home/rrevo/]
Hello World
[Loaded java.lang.Shutdown from shared objects file]
[Loaded java.lang.Shutdown$Lock from shared objects file]

Read java options for more info.

PS: It's time to start blogging again.