• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How to which class is loaded from which jar file alongwith location?

Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please look at the following code :

import org.apache.commons.lang.*;
public class test
public static void main(String Args[])
System.out.println(StringEscapeUtils.escapeHtml("bootstrap classloader: ")
+ String.class.getClassLoader());

When I run the compiled class, i want to know which class is being loaded from which jar and its location.
Using java -verbose solves the problem partially because it show only info about natives jars and classes of J2SE package.
But what about the external jars (commons-lang-2.1.jar)
and their classes ?
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this will be of any help, if it is not, I apologize.

I use Eclipse 3.1 (which is free), putting my mouse over a fragment of code will usually give me back some pretty verbose information. Example:

Hovering the mouse over getLogger

Logger.log = Logger.getLogger(TestClient);

will give me "Logger org.apache.log4j.Logger.getLogger(String arg0)"

This tells me the Object, Method, Package and Arguments.

I know this is not run-time, and you don't get the jar or the jar's directory, however, since you have to add each jar to the Project and you can expand the jar and the package in the Package Explorer View, you know where everything is comming from, moreover, ambigous package class referneces are not allowed (wont compile until fixed).

With that said, one of the biggest reasons I moved from Textpad to Eclipse was the ability to debug conflicting class names, not that it happened very often, however, when it did, it took forever to find the offending jar.
Not so fast naughty spawn! I want you to know about
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic