简体   繁体   中英

Exporting executable/runnable jar in eclipse

I have a problem extracting my current project into an executable jar file. When I'm in eclipse and press the run button everything works fine, but when I do

Export -> Runnable JAR File -> Choose right Project, Libary handling: Extract required libraries into generated JAR -> Finish 

and then start the .jar file; the only thing I get is a window with a grey canvas. It should start the game I programmed (spaceInvaders).

https://github.com/datosh/SpaceInvaders

Here is the link to the github where I uploaded the project. I really don't know where the error is and where to look. In my code? In my installed JRE/JDK? Am I doing something wrong while creating the jar?

Please help -.-

When your app is packages as a JAR, there are no files other than the JAR itself. The File class is only for accessing resources on the local file system, but, as Jon Skeet said, you need to read from the application's classpath when it's been packaged into a JAR. See https://stackoverflow.com/a/3376393/639520

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM