File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to which class is loaded from which jar file alongwith location? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to which class is loaded from which jar file alongwith location?" Watch "How to which class is loaded from which jar file alongwith location?" New topic
Author

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

Danish Sualeh
Greenhorn

Joined: Oct 06, 2005
Posts: 11
Hi,
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 ?
Thomas Bigbee
Ranch Hand

Joined: Nov 29, 2001
Posts: 48
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.
 
wood burning stoves
 
subject: How to which class is loaded from which jar file alongwith location?