Maybe some of you have already wondered what this is.
JAR File
A JAR file is a Java Archive based on the popular ZIP file specification from PKWARE. If a JAR file includes a META-INF directory, the contents will be interpreted by the JVM.
META-INF/MAINFEST.MF
The MANIFEST.MF is used to define extensions and package information for the JAR file.
Manifest Name Value Pairs
The Manifest file can contain a number of Name Value pairs in the form of name: value. Each of theses pairs is delimited by a
newline. Popular names are
Main-Class or
Class-Path.
The Trick
If your application consists of a number of JAR files and you have different entry points, aka Main Classes, you can save a lot of maintenance time by packaging everything as usual and create special JAR files for the entry points.
Sample MANIFEST.MF
Here is a MANIFEST.MF snippet taken from OC4J to explain this:
Manifest-Version: 1.0
Created-By: 1.3.1 (Sun Microsystems, Inc.)
Main-Class: com.evermind.client.orion.Oc4jAdminConsole
Class-Path: oc4j.jar
This way, you refer to the Main Class packaged somewhere in the Class Path (ie.
oc4j.jar in this case). You'll find this snippet in the MANIFEST.MF of admin.jar.
It is important to note that the Class Path is relative to the working directory of the JAR file.
Usage
Using such a JAR file is easy (shown for OC4J's admin.jar):
java -jar admin.jar