I was trying the acm library and when I tried to use the GImage it can't find my image. I tried putting it everywhere and still it can't find it. Where does GImage look for an image(please be specific) thank you
Asked
Active
Viewed 2,545 times
2 Answers
1
According to the docs. it specifically consists of the following steps:
- Check to see if an image with that name has already been defined. If so, return that image.
- Check to see if there is a resource available with that name whose contents can be read as an Image. If so, read the image from the resource file.
- Load the image from a file with the specified name, relative to the application directory or the applet code base.

Andrew Thompson
- 168,117
- 40
- 217
- 433
1
I was also having the same problem. I used the full-path and it worked, e.g.:
GImage img = new GImage("/Users/abc/java/programming/abc.jpg");
add(img);
Also, I just noticed that if you are using Eclipse, you can keep the image inside bin sub-directory and then you can use filename:
GImage img = new GImage("abc.jpg");
add(img);
For the above to work, your image should be at: /Users/abc/java/programming/bin/abc.jpg"

Chandresh Pant
- 1,173
- 15
- 19