Home > Articles

  • Print
  • + Share This
Like this article? We recommend

JAR Indexing

When an application is spread out across multiple JAR files, the runtime process of finding the necessary class in the various JARs can be a lengthy process. The problem is especially exasperated when you are dealing with a larger project consisting of a huge number of JARs which in turn house a large number of classes. The class loader users a linear search algorithm to search through all of the JARs to find a requested resource. You can imagine that when dealing with large network applications, things could get ugly.

As a result, JDK 1.3 added indexing to the JAR file format. Indexing allows the search for classes through project JARs to be optimized.

When a JAR file is indexed, directory information is stored in a file named INDEX.LIST. This file is stored in the META-INF directory of the root JAR file. The sample command below shows sample usage of the JAR indexing feature:

jar –i first.jar subdir/second.jar third.jar

Programmatic Support of JAR Files in Java

The Java language has inherent support for working with (reading and writing) JAR files programmatically. This offering comes in the java.util.jar package. The package was introduced in JDK 1.2. The JarFile class is one of the major classes of the package. See http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/package-summary.html for the an API breakdown of usage of the package.

In the Oven

An interesting Java Specification Request (JSR) currently being developed is JSR 200: Network Transfer Format for Java Archives. The JSR defines a dense download format for Java classfiles. The new format is expected to achieve major size savings over JAR files.


In this article, you were introduced to the subject of Java Archives (JARs). JAR files are ubiquitous in the Java realm. As Java has evolved, so have the offerings of JARs. They are no longer provide just traditional archiving as we see in the ZIP and TAR format. As you were shown, JARs now have innate support for indexing, programmatic creation/manipulation, security, and integrity.


How to Sign Java Code: http://www.securingjava.com/appdx-c/appdx-c-6.html

Security in Java 2 SDK 1.2: http://java.sun.com/docs/books/tutorial/security1.2/overview/index.html

  • + Share This
  • 🔖 Save To Your Account