-2

I've got a problem with loading images implemented in a jar file. Here's my file tree:

    -graphics
    -ImageFiles
         -animation
              -image.jpg
    -mathspace
    -META-INF

Now I wanna load this image:

    ImageIO.read(getClass().getResource("/ImageFiles/animation/image.jpg"));

This works well in the eclipse runtime but when I start it as a runnable jar File a NullPointerException gets triggered. Thanks for help!

Ya3Be
  • 1

1 Answers1

-1
public void init() {
 try {
  img = ImageIO.read(getClass().getRessource("/ImageFiles/animation/image.jpg"));
 } catch (Exception e) {
  e.printStackTrace();
 }
 repaint();
}

public void paint(Graphics g) {
 if (img != null) {
  g.drawImage(img, 0, 0, this);
 }

}
Draken
  • 3,134
  • 13
  • 34
  • 54
Ya3Be
  • 1