I’m programming a GUI in Java (using Swing of course) and while running my application in Eclipse everything is fine and with icons and whatnot, but after exporting my application the icons are gone.
The icons are located under the class-path in the following directory resources/icons.
JButton browseButton = new JButton("Browse", new ImageIcon("resources/icons/browse.png"));
Seems like as guided by @kleopatra, this surely is the right way.
When you create resources folder, make sure you do it by right clicking your project, then go to source folder and name it as resources/icons and then manually put your images in that folder, and go back to your eclipse and refresh your project. Now you can use these images in your runnable jar also.
Now in order to use your image/icon in your Classes use this
Here your
pathwill be the name of theimageprefix it by a forward slash, which is inside yourresources/iconsfolder like"/myIcon.png"I wanted to be sure, before i post my answer, so tested it.
Else give me some time, I will put all steps somewhere for you to see.
More info related to the whole thingy can be found on this another answer of mine :
Load ImageIcon Exception