0

I'm attempting to load an image from inside my Java Applet. I'm receiving a null pointer error. I'm using This SO post as a guide for my code however it is not working as expected. Below are two images of my packages and how they appear inside my JAR.

Packages Jar Contents

The specific code I am using the load the image is as below:

ImageIcon logoIco = new ImageIcon(this.getClass().getResource("/images/logo.png"));

This specific code is being run in the Director class however all the other code in that class works. I know it is the image because if I comment out the line and just make the image null the program works as expected.

I can confirm the image works just fine if I load it as an application or via the command line it does however not work at all inside any web browser I have tested it on. As I am running this locally I have made an exception in my Java security to ensure this isn't an issue and will then test it on default settings once I can get it working.

Why is this not loading?

Community
  • 1
  • 1
Scott
  • 465
  • 3
  • 10
  • 22
  • Can you try `./images/logo.png`? I am not tryed it, but I think the absolute path may be the problem. – azendh Jun 11 '14 at 13:12
  • ./images/logo.png still errors out and then also causes an error via command line which was not occurring before. – Scott Jun 11 '14 at 13:14
  • Do you check this: http://stackoverflow.com/questions/625687/java-getclassloader-getresource-driving-me-bonkers ? – azendh Jun 11 '14 at 13:17
  • Tried every combination in that thread still no dice. – Scott Jun 11 '14 at 13:58

0 Answers0