How to run Java .jar without MANIFEST.MF?

别说谁变了你拦得住时间么 提交于 2019-12-04 10:03:50

问题


Is it possible to run a Java app which doesn't contain MANIFEST.MF file? Of course, there's static main method,just lacks manifest file. And the app is depending on several external .jar files.

If is this possible, how to do that?


回答1:


It is possible, you can specify the class to run from the command line:

java -cp yourJar.jar your.main.Class

Same question here:

How to run a class from Jar which is not the Main-Class in its Manifest file




回答2:


You can also add the manifest, with the following command:

jar  -uvfe  your.jar foo.bar.Baz
java -jar your.jar        # tries to run main in foo.bar.Baz



回答3:


Of course! Just use this:

java -cp MyJar.jar com.example.Main



回答4:


Yes , use this

java -cp myJar.jar package.className



来源:https://stackoverflow.com/questions/15626369/how-to-run-java-jar-without-manifest-mf

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