I have no idea how to get my images to work in a Jar!

Are you getting an error when you run the last code you posted? You code is fine. The location of your images is fine.

I create a jar with a main method that build a frame and this panel. It loaded the image fine.

public class TestPane extends JPanel {
    private static final long serialVersionUID = 1L;
    private BufferedImage image;

    public TestPane() {
	this.setPreferredSize(new Dimension(200, 200));
	
	try {
	    image = ImageIO.read(TestPane.class.getResourceAsStream("/test/Marvin.JPG"));
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }
    
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(image, 10, 10, this);
    }
}

No the way he has it, it won’t work doing “/images/enemy.png”. Since he added that folder to the build path, he can now directly do “enemy.png”.

My build path includes everything under src. What am I missing here?

Test (project)
-src
–org
(class files)
–test
(image files)

Ah but you didn’t specifically right click your resources folder and click “Use as Source Folder”. That’s what is happening in the OP’s image.

This is starting to come together, thanks guys, it’s good to see what it’s supposed to look like haha! I was getting quite confused…
In any case, I remade the images folder from scratch and made sure it wasn’t in the build path or anything, just a plain folder. I put laid it out the you have yours there Ra4king. Good news! It now runs in Eclipse!
Bad news… it still won’t run as an executable jar…

Here’s what it looks like now:

http://dl.dropbox.com/u/1289341/Bugs/wontexport.jpg

Careful, it’s case sensitive when inside a JAR :wink:

Oh my goodness! I can’t believe I did that… Clearly not enough coffee!
Well it WORKS now! Thanks a lot to everyone who took the time to help out an Eclipse newbie like me! :smiley:
…Now I can resume actually coding the thing…

;D

I remember ra4king finding the exact same mistake in my one of my first programs haha.

It’s case-sensitive all the time, the only platform you can get away with it when it comes to the filesystem is Windows. If you want portability, treat everything as case-sensitive all the time.