Often times, this error is causing by the mismatch order between “m” and “f” Jar options.
jar -cvfm manifest.txt example.jar com/mkyong/awt/*.class
The above command will causing the following error :
java.io.IOException: invalid header field at java.util.jar.Attributes.read(Attributes.java:406) at java.util.jar.Manifest.read(Manifest.java:199) at java.util.jar.Manifest.<init>(Manifest.java:69) at sun.tools.jar.Main.run(Main.java:150) at sun.tools.jar.Main.main(Main.java:1044)
Did you spot the error? The “m” and “manifest” is not match, the system is consider your manifest file as “example.jar” :)
The letters “m” and “f” must appear in the same order that “manifest” and “jarfile” appear.
The working command should be
jar -cvmf manifest.txt example.jar com/mkyong/awt/*.class
Please read this article about the correct way to add manifest into your Jar file.