what is java.io.IOException: invalid header field?

后端 未结 5 734
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 04:14

When i try to run the following command :

jar cvfm myjar.jar manifest.txt *.class

I get the following exceptions :

java.io.         


        
相关标签:
5条回答
  • 2021-01-18 04:15

    A stupid mistake to do (which I did) was to do jar cvfm manifest.txt myjar.jar *.class instead of jar cvfm myjar.jar manifest.txt *.class

    0 讨论(0)
  • 2021-01-18 04:16

    Check that your manifest.txt file contains the content in this manner :

    Main-Class: <"package-name">.<"Main-class-name">.class <"newline">

    Note that newline/carriage-return is necessary for parsing.

    Refer to this link http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

    0 讨论(0)
  • 2021-01-18 04:30

    "jar -cvmf" instead of "jar cvfm" should resolve the above error

    0 讨论(0)
  • 2021-01-18 04:33

    I solved a similar problem. It's always the first manifest header makes JAR throw an "invalid header" IOException. So I guess it's the BOM of a utf-8 file makes Jar can't understand. Although I think I have read somewhere that saying a manifest file should utf-8 encoded, I saved my mf file to ANSI with Notepad of Windows, and JAR just stopped complaining about the header name.

    0 讨论(0)
  • 2021-01-18 04:34

    I'm guessing that there's a problem with your manifest file. Give it a look to see if you've got a typo in the name of a header variable.

    0 讨论(0)
提交回复
热议问题