IOException: "Invalid header field; when creating .jar file with manifest

When I enter jar cvfm file_name.jar manifest.txt * .class at the command line, I get this error:

java.io.IOException: invalid header field at java.util.jar.Attributes.read(Attributes.java:410) 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:172) at sun.tools.jar.Main.main(Main.java:1177) 

I have never received this error before, and I can’t find anything on it, what does it mean?

+6
source share
5 answers

Check the name of the header variable in the MANIFEST file. Invalid MANIFEST file.

This tutorial will help determine the MANIFEST file format and related things, http://docs.oracle.com/javase/tutorial/deployment/jar/manifestindex.html

+5
source

Follow the order of the parameters:

 1) jar cvmf manifest.txt some.jar package/*class 2) jar cvfm some.jar manifest.txt package/*class 
+8
source

In case you land here and try everything, and still not get rid of the problem, see if there are any random tabs instead of 4 spaces for indentation in the MANIFEST file.

I used the maven pom.xml file to automatically create MANIFEST, and the property string was too large, spanning several lines as follows:

 <Extension-List> item1 item2 item3 item4 item5 item6 item7 item8 <--- these lines are idented with tabs item9 item10 item11 item12 </Extension-List> 

this greatly distorted the MANIFEST file.

+1
source

Your manifest file must follow the required format . If you create the file yourself, then you should find out where you have the syntax. However, if the manifest file was generated by any tool or process, you will need to check the documentation of the tool to see if you are caught in an error in the tool.

0
source

Read the first line of your manifest carefully, for example:

 Main-Class: main.HelloWorld 

I had this error because I added a space similar to this "Main-Class:"

Perhaps this is something similar.

0
source

Source: https://habr.com/ru/post/954214/


All Articles