开发者

failed to load main-class manifest attribute from abc.jar

开发者 https://www.devze.com 2023-01-29 01:55 出处:网络
HI, I have create开发者_如何学Pythond a runnable .jar file using eclipse and compiled it with jdk1.4.2, i am able to run it perfectly on windows but whenever i run it on unix it says \"failed to load

HI,

I have create开发者_如何学Pythond a runnable .jar file using eclipse and compiled it with jdk1.4.2, i am able to run it perfectly on windows but whenever i run it on unix it says "failed to load main-class manifest attribute from abc.jar" Why is it so

Please help

Saurabh


I usually avoid executable jars. Assuming, we have a class com.example.MyClass that has has main method, then the "executable jar"'s manifest (myapp.jar) needs the line

Main-Class: com.example.MyClass

Then you can start the application like this

java -jar myapp.jar

Apart from some classpath annoyances, this is pretty similiar to

java -cp myapp.jar com.example.MyClass

The "annoyance": if run the application with the -jar option, the classpath has to be defined in the manifest - it will ignore any CLASSPATH entry or -cp attribute. So if you have dependencies, you'll have to copy and paste them from the manifests classpath attribute to the -cp attribute:

java -cp myapp.jar;<other libs> com.example.MyClass
0

精彩评论

暂无评论...
验证码 换一张
取 消