I need to get res folder to compile when I export a executable jar file in eclipse also when I use the getClass().getResource()
method it doesn\'t work.
Either:
or
I have now fixed the problem - this is the code that works
public BufferedImage loadImage(String fileName){
BufferedImage buff = null;
try {
buff = ImageIO.read(getClass().getResourceAsStream(fileName));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
return buff;
}
The value of fileName is just an image name eg BufferedImage img = loadImage("background.png");
Thank you all for your help.