For starters, you need to download the Classpath Helper eclipse plugins. The files are packaged seperately as binaries and source code plugins. The source code plugins are not required for execution.
The latest version of Classpath Helper can be downloaded from source forge http://classpathhelper.sourceforge.net/downloads.html
Once you download the eclipse distribution zip file, you need to unzip it in your eclipse directory (it will automatically unpack itself in the appropriate subdirectory (i.e. plugins). From there (re)start eclipse. You can verify if the classpath helper plugins are properly installed by selecting Help->About Eclipse SDK, select the "Plug-in Details" button.
Eclipse by default starts its VM with a very small heap and stack. This leads to some mysterous stack overflows from within Eclipse when plugins are performing long running jobs. This is a well documented bug within Eclipse that affects other plugins. The work around is to increase the stack size upon eclipse startup.
eclipse.exe -Xms64m
The Classpath Helper Views can be opened in any perspective with the following steps.
First, from the Menu select Window->Show View->Other...
Second, under the Classpath Helper category, select the Classpath Helper View, Location By Location View, or Packages View
The basic layout of this view should be a straight forward translation of the classpath. The classpath is based upon the currently selected model (which initially is taken from the currently selected Java Project from you Package Explorer view).
Familar icons are used for Jar files and class folders. The order is represented top to bottom. The various decorations on these elements will be explained later.
This can be expanded to show the classes and interfaces within each jar or folder.
The highlighted region shows a jar and class file decorated with a .
This indicates that a reference to a class cannot be resolved (found) on the current classpath.
In this example, a class called anunresolvedjar.ClassMissingFromJar
cannot be found.
At runtime this would lead to either a java.lang.ClassNotFoundException
or a
java.lang.NoClassDefFoundError
. In either case, the class
anunresolvedjar.ClassWithMissingDependency
cannot be loaded.
The first highlighted region (next to the ) shows jar and class file
decorated with a . This indicates a class is 'blocked' or
'obscured' on the classpath. This means that the class/interface located at this location
will never be loaded. Instead it is loaded from another location. In this instance, we can
see that the class ajar.DependsOnFilesFromFolder
will actually be loaded from
C:\Development\Sample\demoarea\ajar.jar
.
In the second highlighted region (next to the ) we can see the class
ajar.DependsOnFilesFromFolder
. Although not a critical problem with the
classpath, it could be confusing if the jar
C:\Development\Sample\demoarea\ablockedjar.jar
is updated with a new instance
of ajar.DependsOnFilesFromFolder
as the newer class will never get loaded into
the JVM.
The first highlighted region (next to the shows a folder and class
file with a . This indicates a class is 'blocked' or 'obscured' on
the classpath. This is essentially the same as a yellow rectangle with one addition. The
red color is also an indication that the version of the class at this location
(C:\Development\Sample\demoarea
in this example) is different from the version
that will actually be loaded (from C:\Development\Sample\build
in this
example). As with a yellow rectangle, the folder shown below the blocked
class is the location where the class will actually get loaded from.
As with the previous example, the second highlight is showing the folder where the actual class will get loaded from. Of course blocking locations will always be above (appear earlier) in the classpath.
Classes decorated with the image indicates a class that is not
referenced by any other class. In the above image afolder.AClassWithDependencies
is not referenced by any other class. Keep in mind that this information is based
solely on references maintained within the classfile itself. There are several
notable cases where class files are referenced but this will not be indicated
including:
Class.forName()
is used to load a classes, which
is common in many frameworks including struts, WAR web.xml files, EJB descriptors,
etc.static final
constants) are compiled inline.
This means that although there's a compile time dependency on the constants at
runtime there is no reference to the declaring interface/class.
Class
or Interface
Depends OnIn addition to showing issues or problems with the classpath, Classpath Helper also can
be used to show what classes/interfaces a particular class depends on. The highlighted
region shows that the class ajar.DependsOnFilesFromFolder
depends on
afolder.AClassWithNoDependencies
loaded from C:\Development\Sample\demoarea
blocked.BlocksALaterClass
loaded from C:\Development\Sample\build
In addition to showing locations and classes a class depends on, it is also possible to see which
classes refer to a given class. In the above image you can see the class
SomeInterface
is referenced by blocked.BlocksALaterClass
(which is
located in the C:\Development\Sample\build
folder).
It is possible to apply filtering to the Classpath Helper view. Filtering will only show jars/folders/classes/packages that relate to selected filtering criteria.
The layout of this view initially appears identical to the ClasspathHelper view, however it is intended to show relationships between jars. The decorative icons are the same and essentially have the same meaning. But the Location by Location view can be used to view inter jar information.
This can be expanded in a similar fashion.
The Depends on branch shows which jars/folders that this particular jar depends on.
In this case ajar.jar
depends on both the build
and
demoarea
folders. Within each folder we can see the specific classes
that are depended on.
Also notice the unreferenced icon . As with the classpath helper view, this indicates that the object is unreferenced. However in this view the icon indicates a jar that is not referenced at runtime by any other jar. This can be useful in locating obsolete jars.
The Referenced by Branch is the reverse of the depends on view. It shows which
jars a particular jar supports or is referred to by. In this case, demoarea
is referenced
by itself and ajar.jar
. The references are afolder.AClassWithDependencies
and ajar.DependsOnFilesFromFolders
. The specific class referenced is
afolder.AClassWithNoDependencies
which is refered to by both.
The unresolved branch is similar to unresolved branch from the ClassPath view. The
only difference is that it is showing a summary of unresolved classes for the entire jar. In
this case anunresolvedjar.ClassMissingFromJar
cannot be found.
This view takes a package centric view of the classpath, allowing you to look for classes without knowing or caring about the location of the class. The decorative icons are the same and have the same meaning as the other views.
Packages can be expanded to reveal the contents of a package.
The highlighted region shows a package and class file decorated with a .
This indicates that a reference to a class cannot be resolved (found) on the current classpath.
In this example, a class called anunresolvedjar.ClassMissingFromJar
cannot be found.
At runtime this would lead to either a java.lang.ClassNotFoundException
or a
java.lang.NoClassDefFoundError
. In either case, the class
anunresolvedjar.ClassWithMissingDependency
cannot be loaded.
The first highlighted region (next to the ) shows the class file
DependsOnFilesFromFolder
decorated with a .
This indicates the class is 'blocked' or 'obscured' on the classpath. This means that the
class/interface is available at multiple locations on the classpath. The list shows
areas where this class is blocked.
The second highlighted region (next to the ) shows where the class would actually be loaded from.
The first highlighted region (next to the shows the class
BlocksALaterClass
file with a . This indicates
it is is 'blocked' or 'obscured' on the classpath. This is essentially the same as a
yellow rectangle with one addition. The red color is also an indication that the
version of the class at this location (C:\Development\Sample\demoarea
in
this example) is different from the version that will actually be loaded
(from C:\Development\Sample\build
in this example). As with a
yellow rectangle, the folder shown below the blocked class is the location
where the class will actually get loaded from.
As with the previous example, the second highlight is showing the folder where the actual class will get loaded from. Of course blocking locations will always be above (appear earlier) in the classpath.
Class
or Interface
Depends OnIn addition to showing issues or problems with the classpath, Classpath Helper also can
be used to show what classes/interfaces a particular class depends on. The highlighted
region shows that the class ajar.DependsOnFilesFromFolder
depends on
afolder.AClassWithNoDependencies
loaded from C:\Development\Sample\demoarea
blocked.BlocksALaterClass
loaded from C:\Development\Sample\build
In addition to showing locations and classes a class depends on, it is also possible to see which
classes refer to a given class. In the above image you can see the class
SomeInterface
is referenced by blocked.BlocksALaterClass
(which is
located in the C:\Development\Sample\build
folder).
It is possible to apply filtering to the Classpath Helper view. Filtering will only show jars/folders/classes/packages that relate to selected filtering criteria.
This view scans for jars that are not on the classpath (but are under the current project). It provides basic browsing of packages and classes that are available but not on the classpath. This can be helpful when trying to build up a classpath, as you can quickly browse for the missing classes to see which jars contain them.
The only information this view shows is which jars a class or interface can be loaded from. Only jars from the current Eclipse project that are not already on the classpath are scanned (this image was created by removing previously demoed jars from the classpath).