manifest.mf writing errors...(crazy!)

by now got three errors, this afternoon.

 

===============

Manifest-Version: 1.0
Class-Path: ...

Main-Class: ...

===============

 

"invalid header field":

because I need to refer to a lot of jar files with different directories, I put every jar name with path in Class-Path in one line, separated by TAB. Then I got this error. Remove TAB and use " ", then I get:

 

"invalid manifest format"

This is because although I have replace TAB with SPACE, I am still putting ENTER after each jar to separte them in different lines. Ok, I remove these ENTER, then I get:

 

"line too long"

Now I compromise. I put every line many jars, but not too long. It seems accept ENTER at the end of line, but after the ENTER, you must follow a SPACE right before the beginning of a new line.

 

Now, my manifest.mf works in exporting the project into a JAR file.

 

But, other problem appera when running the new JAR file:

 

"java.lang.NoClassDefFoundError"

Ok, now it cannot even find the entry class. I have to go back to check the manifest.mf again. I remove the SPACE after the Main-Class name and provide a ENTER directly. And after that, I add another ENTER. Now the JAR can start...

 

but when it runs a while, it got the "java.lang.NoClassDefFoundError" error again, for some class. Then I realize that some file name connect together in the manifest.mf, after eclipse make the JAR. So I make every line in Class-Path part end with a SPACE. Now the manifest works perfect!

 

-------------------------------------------------

 

So here is what we need to pay attention when writing manifest.mf:

 

Regarding Class-Path part, end each line with a SPACE, instead of a directly ENTER, when there are too many external jar files you need to link to.

Regarding Main-Class, by ending the current line, you must type ENTER and then ENTER again to keep there is an extra line after the last line of manifest.mf

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章