Two Laptop Bag
The moose likes Java in General and the fly likes How to work out where a jar file is coming from? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How to work out where a jar file is coming from?" Watch "How to work out where a jar file is coming from?" New topic
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
    
  15

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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How to work out where a jar file is coming from?
 
Similar Threads
External Jar file problems in Windows
Base Directory
Jar Files: Kill me NOW.
How to detect a config file when using a shell script to start the app
Lookup problem with local bean