I am using Eclipse, and I wish to export some images in the “img” source folder along with my .jar, so they show up in the JAR.
My Heirarchy is :
Project>src>Package>FILE.java
Then in project is another source folder called :
img>IMAGE.png
I am currently linking to the images using :
lblNewLabel_1.setIcon(new ImageIcon("img/logo1.png"));
And that works fine, until I export it.
I am exporting it as an Runnable JAR file with Extract required libraries ticked, as the middle one will not allow the .jar to open. Extract allows it to open, but the images do not show.
Path are not the same when you load data inside a JAR.
You can use this method to load image when you run from a JAR: