Hi All, I am trying to work out where a jar file is coming from (which directory).
As I am facing a problem with the wrong version of a jar being picked up and used in an application. I presume this is the result of classpath order, or another JVM argument suggesting to do this, but I would like to find out where this jar is.
I was wondering if there was any method of showing where each jar file is coming from (such as a verbose JVM argument which shows the directory listing or something??).
There's nothing wrong the verbose way, aside from verbosity, though I like to use Which4J.
Which4J is a simple utility app that helps you determine where classes are being loaded from. This can be especially helpful in debugging classpath and classloader problems. It serves the same general purpose as the Unix which command except it searches your classpath (or a particular classloader) instead of your shell command path.
Which4J can be run in command-line mode to search your system classpath for all occurrences of the specified classname. More importantly, it can also be used programmatically to search a particular ClassLoader for the first occurrence of the specified classname or Class instance. This can be extremely valuable when trying to debug problems in web containers and application servers that have sophisticated ClassLoader hierarchies.