Browse DevX
Sign up for e-mail newsletters from DevX


Put an End to Jar File and Class Name Conflicts

Uncover hard-to-find class name conflicts and jar file version discrepancies and redundancies with a simple audit utility.

s the number of libraries and APIs proliferate, the number of jar files on a developer's system and on application servers increases exponentially. If you don't manage your system classpath and any additional classes or jar files that your application loads at runtime, insidious, hard-to-identify bugs may arise. Jar files that have the same name but contain different packaging, or identically named classes that contain methods with different signatures can leave you wondering why an application that once worked suddenly fails.

Knowing what's on your system's classpath and understanding Java's classloading mechanism are essential to building reliable applications. Although you could use the Java command line jar utility to display the contents of any of your jar files, typing the command jar tvf [filename] on each and every jar file on your system would be an extremely tedious and error-prone process. This article provides a simple, more efficient utility that enables you to inventory jar files and identify duplicates of both the jar files themselves and the classes packaged within them.

This tutorial discusses how to use this utility, or "auditor" as I refer to it, which you run from the command line. It displays results in a GUI interface (as shown in Figure 1), or saves results as an XML file (as shown in Internet Explorer in Figure 2).

Figure 1: Jar Auditor GUI Display

Figure 2: Jar Auditor XML Output

Thanks for your registration, follow us on our social networks to keep up-to-date