1

My build folder of project has following structure:

build
  |-classes
        |package
             |-HelloWorld.class
  |-resources
        |-images
              |-image.png

There is ImageIcon object in HelloWorld class and its declaration should look like this:

ImageIcon icon = new ImageIcon(HelloWorld.class.getResource("../../resources/images/picture.png"));

But it throws NullPointerException in getResource() method. Where did I make a mistake?

igor.tsutsurupa
  • 189
  • 1
  • 6
  • 2
    nothing better about as [great & crossplatform & cross_IDE & cross_Java_versions tutorial about embeded resources ala strange_animal](http://stackoverflow.com/questions/9864267/load-icon-image-exception/9866659#9866659) by @nIcE cOw +++ – mKorbel Aug 16 '13 at 13:19
  • 2
    Image is in classpath, so you should not require relative path `new ImageIcon(HelloWorld.class.getResource("/resources/images/picture.png"));` – Sachin Thapa Aug 16 '13 at 14:42

0 Answers0