0

I have created a java project and would like to export it. I export it as a runnable Jar file and run it. When I run it the icon image is the java mug but I had set it to change to a custom Icon.

When I run my program through eclipse it works fine. I used:

launcher.setIconImage(new ImageIcon("res/Logo.png").getImage()); 

I set the res file to the build path but it doesnt show when I run it outside eclipse.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
genfy
  • 83
  • 3
  • 4
  • 18
  • 1
    1) Please don't forget to add a '?' to questions! Some people do a search in the page for '?' and if none exists in the 'question' go directly to the next (actual) question in line. 2) By the time of deployment, those resources will likely become an [tag:embedded-resource]. That being the case, the resource must be accessed by `URL` instead of `File`. See the [info page](http://stackoverflow.com/tags/embedded-resource/info) for the tag, for a way to form an `URL`. – Andrew Thompson Jan 01 '14 at 20:14

1 Answers1

0

when you create a jar, the image is no longer in the place you say, replace your code with this:

new ImageIcon(AnyClassName.class.getResource("relative_path/to/the/class/res/Logo.png").getFile()).getImage();

also, extract the jar and make sure the image is in there

Dima
  • 8,586
  • 4
  • 28
  • 57