Java Classpath Debugging with verbose Arguement
Today I came across a useful tidbit for debugging classpaths. A little background: I was attempting to write a unit test using the PowerMock framework to mock a static method. When I went to execute the test, I received an exception that I had two versions of org.apache.commons.logging.Log in my classpath. Looking over my classpath, it’s no wonder. Like most projects, the list of libraries in this project reads more like a history of the project than what it actually uses. Multiple copies of the same jar file…multiple verisions of the same libraries…just a mess (don’t get me started on dependency management…that’s a topic for another day).
So with the help of Google I discovered the -verbose:class JVM parameter. Ever wonder what classes are being loaded in your JVM? Ever wonder who is loading that mysterious class? This is the parameter for you. This option outputs a list of classes loaded and from where. In my case, PowerMock was loading Log and so was a copy of the commons-logging jar file I had in my project. What are some debugging tips you’ve used in the past that may not be every day knowledge? Leave it in the comments!

Blog 
