When I run my program as a Java Application
, everything works fine. However, when I run my program as a Java Applet
, the images do not load, and I get this stack trace:
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at com.asgoodasthis.squares.Tile.<init>(Tile.java:42)
at com.asgoodasthis.squares.Component.start(Component.java:80)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I have a directory named res in my project directory, and I am loading my images like this:
public static BufferedImage tileset_terrain;
public loadImage() {
try {
//loading our images
tileset_terrain = ImageIO.read(new File("res/tileset_terrain.png"));
} catch(IOException e1) {
e1.printStackTrace();
}
}
So how do I get the images to load when I run my program as an applet
? I am using Eclipse
IDE.