I have an Applet I'm trying to embed into a html file after packaging into a jar file.
Images are loaded in the main Applet Class with the following line
return getImage(getClass().getResource("/../content/"+path));
This works when running through eclipse but when I export it to a jar file I get a Null Pointer Exception. I've done some googling and I've tried to use getResourceAsStream with the following code
InputStream is = new BufferedInputStream(
getClass().getResourceAsStream("/../content/"+path));
return ImageIO.read(is);
but this doesn't work through eclipse.
Content is the top level directory of the images and path is the specified path to the required image. The applet is in a folder called game, which is at the same level as content
It was a comment now i answered it here (as OP said it did help): try putting the content into the same package as the class thats accessing the content and change the paths accordingly and see if that helps. If it does, its a problem with your paths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With