Failed to load Main-Class manifest attribute from TextEditor.jar

Hi, I'm trying to make a JAR file containing a Java application that I can run by double-clicking under windows.

Everything works fine, except I get the error "Failed to load Main-Class manifest attribute from TextEditor.jar"

I have tried to set up my manifest file to contain the Main-Class attribute. Eg:

Manifest-Version: 1.0

Main-Class: texteditor/TextEditorClass.class

But I get the error:

java.io.IOException: invalid manifest format

If I include a Name: header...

Manifest-Version: 1.0

Name: texteditor

Main-Class: texteditor/TextEditorClass.class

...then the manifest is used, (and I can even see my Main-Class attribute within the JAR), but if I double-click the JAR or use "java -jar TextEditor.jar" from an MSDOS prompt, then I still get the error message "Failed to load Main-Class manifest attribute from TextEditor.jar"

I am using Java version "1.2fcs" Classic VM (build JDK-1.2fcs-S, native threads)

How do I get the mainfest to accept the Main-Class attribute?

thanks,

Tim

[1137 byte] By [TimRyan] at [2007-9-26 2:14:54]
# 1

Hi,

For the Main-Class attribute, you'll have to specify the class itself and not the classfile.

Try to put this in your MANIFEST.MF:

Manifest-Version: 1.0

Main-Class: texteditor.TextEditorClass

Name: "texteditor"

Hope this helps,

Kurt.

leukbr at 2007-6-29 9:11:24 > top of Java-index,Desktop,Runtime Environment...
# 2

Thanks for the reply Kurt.

Unfortunately I still get the same error. I have actually tried all sorts of combinations of the file with and without "Name:" and with and without .class.

I must admit I never tried it with the Name line second like you showed, but I have now, and it gives me the same old "invalid manifest format" message.

I was wondering if somehow I've ended up with an old version of JAR that cannot handle the Main-Class attribute. The problem is that unlike JAVA, JAR won't tell you what version it is. Any ideas how I might prove I'm running the latest version of JAR? Mind you, I get the same problem at home and at work, and my work version is the latest GenRel one so I think this is pretty unlikely.

TimRyan at 2007-6-29 9:11:24 > top of Java-index,Desktop,Runtime Environment...
# 3

Ahhhh, I've sussed it.

It would seen that JAR doesn't work very well unless your Manifest file name is Manifest.mf. In desperation when I started getting bl**dy zip I/O errors from changing around my manifest file content, I changed it to Manifest.mf, and guess what, it worked first time!!!

Yay! Yay! Yay! God I can't believe it has taken so long to solve this one.

In fact my manifest file is now simply:

Main-Class: texteditor.TextEditorClass

and everything works perfectly.

Thanks for replying anyway Kurt - you might as well have the Duke Dollars.

TimRyan at 2007-6-29 9:11:24 > top of Java-index,Desktop,Runtime Environment...