Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JAR Won't Archive Properly (Invalid Header Field Name)

843789Sep 15 2009 — edited Sep 16 2009
So, I think I've followed the instructions of how to assemble a Jar archive pretty well. I've placed all the necessary .class files in a folder along with a manifest file (mainClass.txt) which is encoded in UTF-8 and has a carriage return at the end of it's only line:
Main-Class: XMLLoader
For some reason though, when I run JAR on it however I get this error:
c:\Sun\SDK\jdk\bin>jar cmf C:\Users\Dave\workspace\XMLLoader\bin\mainClass.txt X
MLLoader.jar C:\Users\Dave\workspace\XMLLoader\bin\*.class
java.io.IOException: invalid header field name: Main-Class
        at java.util.jar.Attributes.read(Attributes.java:416)
        at java.util.jar.Manifest.read(Manifest.java:182)
        at java.util.jar.Manifest.<init>(Manifest.java:52)
        at sun.tools.jar.Main.run(Main.java:132)
        at sun.tools.jar.Main.main(Main.java:1022)

c:\Sun\SDK\jdk\bin>
It looks like there are some junk, non-printing characters before the Main-Class header in my manifest file but I can't find a way to remove them or figure out how to fix this problem. Really need some help with this one guys.

Edited by: Tracekill on Sep 15, 2009 4:44 PM

Edited by: Tracekill on Sep 15, 2009 4:44 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 14 2009
Added on Sep 15 2009
9 comments
1,298 views