This section provides a tutorial example on how to add manifest files to JAR files.
There are two ways to add "manifest" to a JAR file.
1. Adding "manifest" through "jar" command line. Store all your manifest attributes in a file. And specify this file
in the "jar" command line with the "m" option:
jar c[v0]mf manifest jarfile inputfiles
For example, I created my own manifest file called manifest.txt with one attribute in it:
Main-Class: Hello
Remember to press the <Enter> key at the end of the attribute. This will insert a new line character (\n)
to terminate the attribute.
Here is how I added my manifest to a JAR file with the "m" option:
As you can see that "jar" command copied the attribute from my manifest file to the end of the auto-generated
MANIFEST.MF file.
2. Adding "manifest" through META-INF/MANIFEST.MF file. Create META-INF/MANIFEST.MF as a text file. Enter all your
manifest attributes in this file. And include META-INF/MANIFEST.MF as an input file to JAR file.
For example, I created my own META-INF/MANIFEST.MF with a text editor as:
Manifest-Version: 3.3
Created-By: Herong Yang
Main-Class: Hello
Here is how I added my manifest to a JAR file with the "M" option: