I want to set an icon for my application in Java. I’m using Eclipse.
I don’t know if the way of storing the icon (and the config file by the way) into the project is the best one (I accept suggestions to learn the best way).
Anyway I’m trying to use this line into my extended JFrame class:
setIconImage(Toolkit.getDefaultToolkit().getImage("img/icon.png"));
But doesn’t work: still with the coffee cup icon.
How can I access to the icon into package estacionBase.img? Is there a better place to store it? How would I access it then?

Instead of saving your resources alongside your source files, save it outside
srcin a folder called something likeres. It’s a good idea to separate your source from your resources.As for the icon, use
setIconImage(ImageIO.read("res/icon.png"));However:
If your icons are inside a
jar, you’ll have to useImageIO.read(Classname.class.getResource("res/icon.png"));I think that’s right, however take care with your relative paths and if it’s not working, the first thing to check would the your paths relative to where it’s being executed from (whether that’s from the .class dirs or from a jar at some stage).