I have just finished my first proper java program with a GUI, and have set all of the options in netbeans in order for the project to create a .jar file which is currently displaying my Frame and connecting to the database. The issue I am having is that when I run the program (I have to run it from terminal as clicking the .jar might be part of the issue?), none of my images load. I have tried the following;
- Going into project Library preferences, and adding the /img folder which resides within my P3Game folder (root dir of the project) with no avail.
- Tried directly copying the images to the generated /dist folder but then I cant add the images via the library pref's due to it not being a folder or library.
- Manually copying over the img folder into dist (after compiling) and setting the file path to
dist/img/imgName.png
and it worked, however, any time I build/ compile the project, the img folder within dist gets completely wipes (just the contents)
ANY help would be much appreciated.
EDIT1: this is how im adding the images into the program, and this works from netbeans, but not from running the program elsewhere.
public void setGrassIcon() throws IOException {
this.grassIcon = new ImageIcon(ImageIO.read(new File("img/Grass.png")));
}