Hi,
I intended to post about a porblem with my litte Tileengine but when putting a testcase together i got an other problem while making a nice webstart for you.
I’m using Eclipse for development and load my Images (located in a sub folder “res/”) like:
public BufferedImage loadImage(String ref) {
...
BufferedImage source = null, target = null;
java.io.File url = new java.io.File(ref);
try {
source = ImageIO.read( url );
}
catch( IOException ioe ) {
System.err.print( "Error while loading '" + ref + "': " );
ioe.printStackTrace();
}
...
}
where String ref is something like “res/box.png”
java.io.File url = new java.io.File(ref); won’t work out for jars so after searching the web a bit I tried:
java.net.URL url = ((java.net.URLClassLoader)ResourceLoader.class.getClassLoader()).findResource( ref );
java.net.URL url = this.getClass().getClassLoader().getResource(ref);
java.net.URL url = Thread.currentThread().getContextClassLoader().getResource(ref);
non of them will work neither directly in eclips nor exported as jar file and I don’t have any ideas left.
Maybe you can give me a hint in the right direction.
The full testcase (including Eclipse project files) can be found here (38kb jar file which will not run of course the problems mentioned above).