Java ARchive (JAR) Files 101
More About Manifest FileManifest is a simple text file that contains all the directions for how the JAR file will behave. When you used the jar command and created MyApplication.jar, a default MANIFEST.MF file was created under the META-INF folder. This is the default folder in which the MANIFEST.MF file is placed.
The MANIFEST.MF file contains the version of the manifest specification and information about the JDK in which it was created (see below). These are standard details that will be part of all manifest files.
Contents of the manifest file Manifest-Version: 1.0 Created-By: 1.5.0_19 (Sun Microsystems Inc.)
Remember the line Main-Class: com.mycomp.demo.MyApplication that you added to the manifest file earlier? You can do this by either editing the manifest file in the JAR or by using commands.
Contents of the main-class-file Main-Class: com.mycomp.demo.MyApplication <This is a new line, which is necessary for the parser to parse this file.>
In addition to all this great stuff, Class-Path is one of the most widely used metadata attributes in manifest files. Like any Java class path, you can extend Class-Path to be part of a JAR file too. The syntax is similar to Main-Class and, in this case, it is Class-Path: <file-name1> <file-name2>. You can place this in a file similar to your main-class-file.txt or in the same file and the manifest update command will do the job for you. By definition, class paths are essential for your application to locate different classes that it will use during its execution.
For Further Reading
About the AuthorSridhar M S is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Page 3 of 3