90% probability that it's just looking in the wrong place.
You can try
System.out.println(new File("xxx").getAbsolutePath());
(with your own file names) to see exactly where Java is expecting to find them.
JamesCherrill
... trying to help
8,516 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
Where it will be executed. First thing in the main() method would be a good spot.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What is the difference between the paths that are printed out in the two places you execute the code?
The getResource() method will search on the classpath.
The other uses the current directory.
Both techniques should work depending on where you put the image file. Can you expain the folder locations for the files, the current folder and the classpath.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
You can see from the print outs that all the paths are different. That means that if you use getResource() it will look in one folder and if you use a relative path to the file it will look in another location.
Each IDE sets the paths to different places. You have to locate the image files for the IDE that you are using.
If you are going to put the program and image files in a jar file, use the getResource() method and copy the image files to where the IDE sets the classpath.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16