Based on feedback from URL to load resources from the classpath in Java i have changed my project, to include my image resources into Images.jar
My project setup is now
/program.jar
/Images.jar
In my code i load my images using
InputStream connectedImage = ClassLoader.getSystemResourceAsStream("images/logo.png");
My Eclipse setup is
/src/...
/images/logo.png
My problem
Eclipse cannot find the Systemresource based on that url.
In order to get it to work, i have to
- Manually create Images.jar containing my image folder
- Add the Images.jar file to the Eclipse project
What I need
-
How can i configure Eclipse so i can
use the same code to load the image
from either Images.Jar (if run from
commandprompt) or from the images
folder(if run from Eclipse)? -
Is there any way to make Eclipse
include my /images/ folder when
creating a runnable jar file of my
program? Currently it does not
include anything besides refereced
jar files and source code.
This is what I usually do:
change the code to:
UPDATE: with 1, you can export the images on the same jar as the classes