How the manifest file is contained in the META-INF subdirectory of the jar file named MANIFEST.MF. Each time you create a jar command file for the command line with the jar cvf command Jarfilename FilesToadd , a default manifest file is then created. You can view this file and get an idea of ββthe actual manifest file. To extract the manifest file from the jar type, run the following command in cmd jar xvf Jarfilename now the META-INF subdirectory will appear in the base directory where you can view the default manifest file. Sometimes when updating a manifest file, we get java.io.IOException: invalid manifest format . This error occurs due to the following reasons:
1. Perhaps you did not leave a space between the name and value of any section in the manifest file,
for example Version: 1.1 , instead write Version: 1.1 , that the space between the colon and 1.1 really matters.
2. Until you specify the main class, you could add the .class extension at the end of the class name. Just specify the main class by typing Main-Class: Classname .
3. Perhaps you did not add a new line at the end of the file. You do not need to write \ n to indicate a new line, but simply leave the last line of your manifest file empty, which will serve the purpose
4. Your text file for the manifest should use UTF-8 , otherwise you may run into some problems.
Finally, I provide an example of what the manifest file should look like. Here is the calculator package, and the main class is Calculator.java
Manifest Version: 2.1
Created-By: UselessCoder
Package Name: Calculator
Class Name: calculator.Calculator.java
Main-Class: calculator.Calculator
source share