Try this:
InputStream in = Tester.class.getResourceAsStream("your/path");
Image image=null;
try {
image = ImageIO.read(in);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(image);
The value or your/path
is either appResources/img/GESS.png
or /appResources/img/GESS.png
depending on your maven configuration and the directory you setup for your project.
For instance, if you add the following entry to your pom.xml
file:
<resources>
<resource>
<directory>src/main/appResources</directory>
</resource>
</resources>
Then, you can get the same resource by using a shorter path since your program knows where to look for resources:
InputStream in = Tester.class.getResourceAsStream("img/GESS.png");
Image image=null;
try {
image = ImageIO.read(in);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(image);
More info here and here.