• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to work out where a jar file is coming from?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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":

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic