What is Jlibtracker?
Jlibtracker - Java library tracker, is the application targetting the common need of most of the projects. During the life-cycle of a project development it common that we add many library dependencies. As the project development time increases or over a period of maintainance of the project the library directory will end up having a huge list of libraries - libraries used by the project, libraries used by the libraries that our project depends on (we call it transitive dependencies) and unused libraries. The Jlibtracker is a command-line utility which helps you find out the libraries required by the project. It also lists the transitive dependencies (that is, the library dependencies of the libraries which are required by your project) and duplicate libraries.
How to run Jlibtracker?
To run the application you need Java 1.5 or above and the Path environment variable to properly set.
Download the file jlibtracker.jar and save it. The syntax and options for executing the application is as below
Java -jar jlibtracker.jar <options>
Options: -s
- -s: Using this option you specify the location of compiled source code. The valid entries are directory containing .class files or jar files, or an absolute path of a class or directory. Multiple entries can be specified by delimiting with semi-colon (;).
-
-i: If you want to explicitly specify the usage of class (es) this option can be used.
This can be used to specify classes that are being used elsewhere like build-scripts or through dynamic loading. This option is optional.
For instance, in build.xml you may have a taskdef defining the usage of com.sun.tools.xjc.XJCTask. Since, this usage will not be figured out by parsing source classes, this class can be specified as include class as –i com.sun.tools.xjc.XJCTask.class.
- -l: Using this option you specify the location of libraries used by the project. Your project has dependency on the libraries in these locations. The valid entries are directory containing classes or jars, or an absolute path of a class or directory. Multiple entries can be specified by specified by delimiting with semi-colon (;).
- -o: You can redirect the output to a text file using this option. This option is optional.
Sample Execution:
$ java -jar jlibtracker.jar -s /dev/myproject/build -l /dev/myproject/lib;/dev/myproject/unusedlib
Parsing source classes...
Finding code dependencies...
Code Dependencies:
/dev/myproject/lib/httpcore-4.1.jar/dev/myproject/lib/mail.jar
/dev/myproject/unusedlib/commons-lang-2.4.jar
/dev/myproject/lib/xbean.jar
/dev/myproject/lib/commons-logging-1.1.1.jar
/dev/myproject/lib/velocity-dep-1.5.jar
/dev/myproject/lib/httpclient-4.1.jar
/dev/myproject/lib/log4j-1.2.15.jar
/dev/myproject/unusedlib/velocity-dep-1.4.jar
/dev/myproject/lib/jaxb-api.jar
Finding transitive dependencies...(this may take few minutes)
Transitive Dependencies:
/dev/myproject/lib/xml-apis.jar/dev/myproject/lib/activation.jar
/dev/myproject/lib/commons-collections-3.2.1.jar
/dev/myproject/lib/jaxrpc.jar
/dev/myproject/lib/commons-beanutils.jar
/dev/myproject/lib/ezmorph-1.0.4.jar
/dev/myproject/lib/xml-apis-ext.jar
/dev/myproject/lib/commons-codec-1.3.jar
/dev/myproject/unusedlib/xmlParserAPIs-2.6.1.jar
/dev/myproject/lib/jgroups.jar
Finding duplicate libraries...
Duplicate Libraries:
/dev/myproject/unusedlib/velocity-dep-1.4.jar is duplicate of /dev/myproject/lib/velocity-dep-1.5.jar/dev/myproject/unusedlib/commons-lang-2.4.jar is duplicate of /dev/myproject/lib/velocity-dep-1.5.jar
Code dependency tracking completed.