Why is jar ignoring my manifest?

◇◆丶佛笑我妖孽 提交于 2019-12-01 15:31:22

问题


I tried to create an executable jar using this command:

jar -cvfm h.jar Manifest.mf Whatever1.class Whatever2.class

The manifest contains this:

Main-Class: Whatever1

But if I try to run the jar, I get: Failed to load Main-Class manifest attribute from my.jar. I extracted the jar, and I saw that the contents of it's manifest were this:

Manifest-Version: 1.0
Created-By: 1.6.0_18 (Sun Microsystems Inc.)

Why was my manifest ignored?

EDIT: I know that using the -e flag I can specify an entry point, and jar will generate a correct manifest, but I'd like to know how to make this version work.


回答1:


Add a line break after the last line of Manifest.mf




回答2:


I've noticed that not having a newline at the end of the manifest file causes this problem at times. See if adding a new line at the end of the manifest file helps.




回答3:


I suppose you have to run jar like:

jar -cvf h.jar -m Manifest.mf Whatever1.class Whatever2.class

Because values for options come directly after the option itself.



来源:https://stackoverflow.com/questions/2169188/why-is-jar-ignoring-my-manifest

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!