My images will not load when running a JAR file exported from Eclipse.
I have the images in a resources class package. I've tried a images source folder as well with no luck.
Works perfectly when loaded from Eclipse. The images are in the exported JAR file, so they're exporting fine.
I've tried:
label.setIcon(new ImageIcon(MainFrame.class.getResource("/resources/header.jpg")));
I've also tried:
URL url = getClass().getResource("/resources/header.jpg");
Image image = Toolkit.getDefaultToolkit().getImage(url);
label.setIcon(new ImageIcon(image));
And:
try
{
label.setIcon(new ImageIcon(ImageIO.read(getClass().getResource("/resources/header.jpg"))));
}
catch (IOException e1)
{
e1.printStackTrace();
}
Any suggestions?
I found that when you changed:
to
in the Set up Launch config it worked for me.
The problem was I had this project in my Windows profile... that had an "!" in it... (DeNitE! -> was the name of my Windows profile)
As soon as I changed it to DeNitE (without the !) it worked fine...