Title speaks for itself. I've made a clone of space invaders which uses several image assets. How do I tell eclipse to export the image files into the runnable JAR so they can be used by the program? I'm using eclipse europa.
Asked
Active
Viewed 1,884 times
2 Answers
2
As Mr. Anderser pointed out, make sure to read them as resources when inside of a jar, not files.
This might help.
Toolkit.getDefaultToolkit().getImage(getClass().getResource("images/imageFile.png"));

MarGar
- 465
- 5
- 12
0
Images inside jar files must be read as resources and not plain files.
You can create a new sourcefolder, e.g. named "images", and put your images in there.

Thorbjørn Ravn Andersen
- 73,784
- 33
- 194
- 347
-
Ok, I've made a new folder and put my images in it. When I ask eclipse to build the JAR and open the JAR with winrar, the folder doesn't get exported – imulsion Sep 18 '14 at 20:33
-
Ensure that the source folder containing your images shows up in the workspace you currently are using in eclipse. You should be able to see the Project -> src -> Package -> Classes [inside the package with the classes, you should see a folder named "images".] Then when exporting, you want to select the classes and the folder to export. – user2494817 Sep 18 '14 at 20:37