I have finished a project and I have been testing it by running it through IntelliJ Idea and it was working fine. I created a.jar executable file but when I run it the images I used for the GUI are not being displayed. I did some searching about that problem but I didn't quite understand how I am supposed to include the resources folder (where the images are stored) into the.jar file. I added two images of how the GUI should be displayed and how the.jar file displays it. Can I get some help please?
Thank you in advance!
I access the images like that:
JLabel lbl = new JLabel("", new ImageIcon("src\\resources\\background.png"), JLabel.CENTER);
Follow these steps:
click project -> properties -> Build Path -> Source -> Add Folder and select resources folder.
create your JAR!
EDIT: you can make sure your JAR contains folder by inspecting it using 7zip.
Reefer this link as well How do I add a resources folder to my Java project in Eclipse
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.