I have an Eclipse Java project with about 10 external jar dependencies. It works fine in Eclipse, also I export it using tools like ONE-JAR and it works fine.
The strange problem I am facing is with images. I have all images in a package inside the project, and when exported they are included but they do not show in the running project?
I have no idea why? Strangely, in some JPanel text, I use HTML with embedded images using e.g:
URL url = myClass.class.getResource( "icons/icon.png");
and this works and shows those images at output, but the ones directly referenced by Java, e.g:
this.setIconImage(Toolkit.getDefaultToolkit().getImage("src/icons/icon.png"));
do not work. This same line of code works perfectly when running from Eclipse. Can you please suggest what could be the problem, or what should I do while exporting this project. Should I switch to Ant or Maven???
You should do this:
Toolkitprovides a method accepting a URL as well, seejava.awt.Toolkit#getImage().