开发者

JAR file—nothings happens when I run it

I'm trying to run a JAR file and nothing happens? Any idea why? Did I maybe do the export wrongly?

Some guidelines would be very welcome!

update

I sorted it!! Thanks for yr brainstorming anyway! I wasn't adding the file with the visual-material (gif-files). I think I added in t开发者_如何学Pythonhe code a try-catch that check if there is any available map if there's not it'll shut down.


Jar files can only be executed if they contain a META-INF/MANIFEST.MF that specifies the main class (entry point) into your application. Otherwise you have to specify the class manually on the command line.

e.g. it contains

Main-Class: com.mycompany.App

Then you can just say:

java -jar MyApp.jar

Normally you would create a manifest.txt containing this line and package it in your jar like so:

jar cfm MyApp.jar Manifest.txt com/mycompany/*.class

Java 6 also implements a parameter on the jar tool which will create/modify the entry point in an existing jar's MANIFEST.MF if you prefer.

jar cfe MyApp.jar com.mycompany.App com/mycompany/App.class
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜