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
精彩评论