Every developer who has used Java is familiar with the
classpath. Usually it doesn't take long to generate your first
The rules for for classloading are well documented and
easily understood. For example if your classpath reads
most developers will tell you that first the classloader will search jar1 for
classes, followed by jar2 and jar3. If you ask them what would happen if the
same class is located in jar1 and jar2, most should realize that only the
version located in jar1 will get loaded. The situation is complicated slightly
with container based classloadering where hierarchies of classloaders are used,
but even then the rules are usually well documented.
It's not the understanding that makes tracking down
classpath errors difficult, it's the volume of the task.
Have you ever added a class to the classpath but weren't sure if it was being obscured by another version elsewhere on the classpath?
Have you ever added jar and wondered what other jars are needed for that jar to function properly? In other words what jars is this jar dependent on?
Have you ever looked at the jars on a project and wondered if all of them are still needed, or just remain as some historical artifact?
Have you ever run a J2EE application in a container and found your application just not running and suspected that the container has introduced an incompatible version of an XML parser?
All of these issues are well known situations with Java and until now the tedium of looking jar by jar was the only way to resolve them. Classpath Helper provides a simple visual way of quickly seeing all of these issues.
How it Works
The core of Classpath Helper is a classloader that does more than just loading classes into the JVM. Classpath Helper not only records the exact location where a class is loaded, it also searches the classpath in proper order (including hierarchies of classloaders) looking for other locations for that same class. It verifies the bytes to determine if the class bytes from blocked classes are the same or different.
Classpath Helper also reads the byte code directly
searching its class definition for dependencies on other classes. A reference to
a class not found on the classpath would normally cause a ClassLoader to fail
with the well known
but Classpath helper is able to bypass these limitations with its independent
reading of the byte code. This allows Classpath Helper to merely report on
missing class references instead of running into errors. A class that can not
find its dependent classes cannot be properly loaded into the VM.
Showing you the information
Classpath Helper provides easy views in Eclipse for quickly processing this information to help you resolve errors.
Class Path View
The basic Class Path View breaks down the information in the very familiar form of jar/folder locations with classes inside of them. This flattened view even shows the correct order when loading via a hierarchy of class loaders. The various icon decorations make it easy to spot potential issues.
Location by Location View
The Location by Location View provides a higher level of abstraction when showing the class related information. Instead of drilling down immediately to the class level. Location by Location shows dependencies and references at the jar level. It even shows all the unresolved classes for an entire jar.
The Packages View organizes the class path information around the notion of Java packages. This is useful in cases where the location is not known or not important.
Not on Classpath View
The Not on Classpath View provides a quick way of scanning jars in the current project that are not on the classpath. This is useful when building up an Eclipse project and a large number of legacy jars exist that you might not need. So preferably you can scan for classes you know you need and only add the jars you still use.
A Detailed description of this view is located in Getting Started
Eclipse by default initializes with a very small JVM stack size. It is important to configure Eclipse to run with a larger stack size. This can be accomplished via the -Xms attribute applied to the eclipse commandline. Failure to do so will lead to out of memory errors in Eclipse.
Classpath Helper was designed with extensiblity in mind. By providing a highly configurable ClassLoader as the base data model, it's possible to simulate the class loading of nearly any class loading environment such as J2EE servlet or application container. Classpath Helper makes writing your own ClassLoader model easy and even supplies a tutorial.
Although reading the Java byte code provides comprehensive access to the dependencies between Java classes, there are two notable areas that cannot be inferred from the byte code.
|Dynamic loading via
||Because the String values supplied to
||In Java it is common to define constants in an
Interface that is referred to in other classes. For performance reasons
Java compilers inline |
Know detail click this link.
Recommend the tutorial