What's this? A JAR File with MANIFEST.MF Only?
By Olaf Heimburger-Oracle on Sep 26, 2007
Maybe some of you have already wondered what this is.
JAR FileA 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.MFThe MANIFEST.MF is used to define extensions and package information for the JAR file.
Manifest Name Value PairsThe 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 TrickIf 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.MFHere is a MANIFEST.MF snippet taken from OC4J to explain this:
Manifest-Version: 1.0This 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.
Created-By: 1.3.1 (Sun Microsystems, Inc.)
It is important to note that the Class Path is relative to the working directory of the JAR file.
UsageUsing such a JAR file is easy (shown for OC4J's admin.jar):
java -jar admin.jar