Note: This is a created using netbeans 5.5 and can be imported as a NetBeans project

JarDepend analyzes the interdependencies between jar (java archive) files. This is useful to add 
only the required dependencies in the CLASSPATH. 

This program was developed to address the bad practice of adding all the jars to the 
CLASSPATH. Frequently seen in java launchers (unix shell scripts) that had all the 
jars in every location onto the java CLASSPATH.

I couldn't find one utility that given a jar file and a CLASSPATH, analyses the jar 
and show the dependencies of that jar file.

How it works:
JarDepend works by analysing the jar (provided by the -jarfile option) and the 
java class files it contains. It then searches through the classpath (provided by 
the -cp option) for the dependent jars.

Since the source code may or many not be present, and is often not quiet useful, 
the analyzer works by analyzing the references of the compiled class file. This 
is stored in the Constants Pool section of the class file header as specified 
in The Java Virtual Machine Specification (chapter 4. - The class File Format).

It then tries to finds the classes referred by the class file in the specified 
classpath (provided with the -cp option). The classes found are then checked 
recursively for dependencies. If a classfile is not found, the native classloader 
is asked to search the classes.

In case the native classloader fails to load the classes, then the class is 
flagged as not found.

The output options of the program are:
showjarsused: outputs the jars that satisfy are required by the jar file
showclassesnotloaded: outputs the classes that could not be loaded
showclassesloadedfromjars: outputs the different classes used by the jars
showclassesloadedfromdefaultloader: outputs the classes loaded by the native classloader

Known Issues:
In case of dependency injection (especially so with spring) since the classes are 
present in the XML context, they cannot be analysed. However, this subset is usually 
very small and I most cases, the dependencies are analyzed correctly.


useage : java -jar jardepend [-options] -jarfile jarfilename -cp classpath

  jarfilename is the fullpath to the jarfile to analyze
  classpath is the java classpath to search for dependencies

where options include:
-showjarsused        	  		to display the jars that are being used
-showclassesnotloaded                	to display classes not located
-showclassesloadedfromjars           	to display the clases referenced external jars
-showclassesloadedfromdefaultloader  	to display jre classes used

classpath       is the colon ':' seperated classpath of all the jar files that need to be searched

