| Author |
How to work out where a jar file is coming from?
|
Thomas Young
Greenhorn
Joined: Jul 17, 2008
Posts: 29
|
|
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??). Kind Regards.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
Hi Matthew, Welcome to JavaRanch! The "-verbose" switch shows each class that is loaded, and where it came from. A few lines out of the hundreds I see when I start an app with "java -verbose":
|
[Jess in Action][AskingGoodQuestions]
|
 |
Taariq San
Ranch Hand
Joined: Nov 20, 2007
Posts: 189
|
|
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.
|
 |
 |
|
|
subject: How to work out where a jar file is coming from?
|
|
|