-1

ImageIcon icon= new ImageIcon(getClass().getResource("image path"))

doesn't work after creating jar file in netbeans. So my jar file can not run but when I run in netbeans it works perfectly please help me.

thor
  • 21,418
  • 31
  • 87
  • 173
  • 1
    See the [examples cited](http://stackoverflow.com/tags/embedded-resource/info) in [tag:embedded-resource] – trashgod Mar 30 '16 at 18:35
  • Possible duplicate of [Load Icon Image Exception](http://stackoverflow.com/questions/9864267/load-icon-image-exception) – VGR Mar 30 '16 at 19:57

2 Answers2

0

You must tell NetBeans that it should pack your image directory into the jar.

Axel
  • 568
  • 7
  • 18
0

Use get getResourceAsStream instead

ImageIcon icon= new ImageIcon(getClass().getClassLoader().getResourceAsStream(String))

This link

Community
  • 1
  • 1
An Do
  • 309
  • 1
  • 8