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

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值