Reputation: 508
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 -.-
Upvotes: 0
Views: 1023
Reputation: 32895
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
Upvotes: 1