JarAnalyzer Page Index (Download JarAnalyzer 1.2)

JarAnalyzer 1.2 Released
Important JarAnalyzer 1.x Information?
What is JarAnalyzer?
What's the Difference between 1.0 and 1.1/1.2?
Where do I get JarAnalyzer?
How do I run JarAnalyzer?
What's the difference between .xml and .grph output formats?
How do I interpret the xml output?
How do I generate the visual representation using the .grph file?
How do I run JarAnalyzer with Ant?
How do I use JarAnalyzer with JUnit?
How stable is JarAnalyzer?
What's next for JarAnalyzer?

JarAnalyzer 1.2 Released

On July 31st, JarAnalyzer 1.2 was released fixing significant bugs due related to J2SE 5.0. This blog entry describes the details. All the download links on this site have been updated to obtain the newest version. If for some reason you need the older version, you can still download JarAnalyzer 1.1. I don't know why you would. Instead, download JarAnalyzer 1.2 now.

Important JarAnalyzer 1.x Information

On April 6, 2006 JarAnalyzer 1.x was officially released. 1.x is a major upgrade from previous versions. Here's the scoop on 1.x:

  • Internally, the class structure and names have changed. The utility was also brought under test, and the design improved.
  • A stylesheet was included in the distribution that allows you to format the xml output in an easier to read format.
  • Metrics have been included in the output.
  • The Ant task now has the ability to filter packages and jars from the output and calculations.

I've done my best to update the documentation on this site. But I may have missed something. If you notice inconsistencies, please let me know. My contact information is on the about page.

What is JarAnalyzer?

JarAnalyzer is a dependency management utility for jar files. It's primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files. The output is an xml file representing the PhysicalDependencies between the jar files.

For more information on PhysicalDependencies, including a variety of design patterns, check out Extensible Java.

What's the Difference between 1.0 and 1.1?

A subtle, yet pretty nasty bug surfaced recently in version 1.0. While JarAnalyzer was always good at detecting cyclic dependencies among two .jar files, if a cycle existed among more than two .jar files, JarAnalyzer experienced some significant problems (ie. StackOverflowError). Ironically, this only occurred when calculating the Level of a .jar file because when calculating the Level, the entire hierarchy of .jar files is traversed to determine where the current .jar resides. Unfortunately, JarAnalyzer didn't handle this well, and the result was an endless loop. Since Level was not a wildly popular metric, I chose to remove the functionality in 1.1. Eventually, I hope to find the time to add Level back into the output, albeit correctly. But when I do that, I also want to make sure JarAnalyzer understands more than just "2-jar" cycles. That's going to be a bit more work, and a bit more time. That's the difference between 1.0 and 1.1. 1.0 has Level. 1.1 does not. All other features remain the same.

Where do I get JarAnalyzer?

Here's the binary version. I've also made the source code available, including the Ant build script. If you want to build JarAnalyzer, you'll need to have Ant and JUnit installed. Assuming you do (and you should), just execute the build.xml file.

How do I run JarAnalyzer?

Running JarAnalyzer is easy. Download the binary version, unzip the file, and execute the runxmlsummary.bat or rundotsummary.bat file. Type in the name of the directory with the jar files you want to analyze. Next, type in the name of the output .xml or .grph file.

You can also specify filters to exclude certain packages in jar files when examining the dependencies. This will help minimize the number of unresolved dependencies on packages that you are not interested in reporting on. The default filter in Filter.properties is to exclude all packages beginning with java. and javax. You can also choose to filter specific jar files.

What's the difference between .xml and .grph output formats?

The .xml output is a data intensive document showing more complete information about each .jar file included in the report. The .grph is a DOT formatted file that can be used with GraphViz to generate a visual representation of the .jar file relationships.

How do I interpret the xml output?

The output is an xml file of the dependencies between the jar files in the directory specified when JarAnalyzer was run. Here's a listing of the primary elements that JarAnalyzer reports on.

  • JarName: The name of the jar file analyzed.
  • Statistics: Number of packages and classes in the jar file. Inner class are included in this count. The Level represents where in the hierarchy a jar file resides. Level 1 components are at the bottom. Level 2 depend on at least one Level 1. Level 3 depend on at least one Level 2. And so on.
  • Metrics: These are based on the "Martin Metrics".
  • Packages: Names of the packages in the jar file.
  • OutgoingDependencies: Dependent jar files based on what was found in the directory being analyzed.
  • IncomingDependencies: Jar files dependent on this jar file.
  • Cycles: Lists the jar file's cyclic dependencies.
  • UnresolvedDependencies: Names of packages not found in the jar files in the directory being analyzed.

I took the liberty of running JarAnalyzer on some popular open source projects. These runs include all of the jars included in the downloads for each of the projects. The Spring output analyzed over 60 jar files. Here's the output xml files generated.

In 1.0, a stylesheet was included that allows you to transform your xml output to a much nicer looking format. Here are some examples of Struts and Hibernate.

How do I generate the visual representation using the .grph file?

You can run DOT directly on the .grph file, or include the DOT run in your Ant build script. Here's an example of how to use it with Ant. To generate the diagram at a command prompt, just copy the arg line section from the Ant task. Here is an example a visual component diagram for Struts and Hibernate.

How do I run JarAnalyzer with Ant?

There is an Ant task available. Here's an example of how to use it.

How do I use JarAnalyzer with JUnit?

You can use JarAnalyzer within your JUnit to check a directory of .jars and verify that no cyclic dependencies exist. Here's an example.

How stable is JarAnalyzer?

I've done extensive testing of JarAnalyzer on a variety of applications and open source software. In the past, I've run into some problems with memory usage when analyzing large applications. To the best of my knowledge, this problem has been resolved. At this time, I am not aware of any bugs in JarAnalyzer. That doesn't mean none exist though, and if you do find that JarAnalyzer isn't working correctly for you, please let me know. JarAnalyzer is released under the BSD License.

  • Another feature you may may come across is that JarAnalyzer only looks for the packages imported by a class, but it does not look inside that package to find the class referenced. So if the same package structure is found in more than one jar file, JarAnalyzer will report a dependency on all jars containing that package, even though the compilation dependency may only be on one of those .jars. There are a couple of reasons for this. First, you shouldn't have jar files with the same package structure. Second, I didn't think anyone would actually do this, so when writing JarAnalyzer I didn't consider this scenario.

What's next for JarAnalyzer?

I do plan to keep working on the utility. There are a number of features I want to add. Here's a list of mine:

  • Eliminate need for bcel library and roll my own class parser.
  • Allow for ability to feed the Filter.properties at the command line.
  • Create a GUI.
  • With GraphViz, allow for different output diagrams.
  • Fix Filter.jars so it doesn't show any aspect of jar in output. Currently, it shows incoming if a .jar is filtered.

If after using JarAnalyzer, you find other features you feel would be valuable, let me know what they are, and I'll add them to the list.

What's the history behind JarAnalyzer?

To do!

Areas (Search) (RSS Feeds)

JarAnalyzer (download now)
AssAnalyzer (download now)
My Resume

My Planet

Speaking Gigs

Please see My Schedule sidebar on my blog for up-to-date speaking engagements and events.