2

The following code is running fine when i run the application from netbeans

ThumbnailLabel lblImg =new ThumbnailLabel(new javax.swing.ImageIcon(
    getClass().getResource("/jewelleryerpapplication/GUI/resources/NoPicture.png")));

Then I clean build the solution as mentioned in different posts for this issue.After that when i double click App.jar from dist folder then following exception occurs.

  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:138)
  • try passing through the classloader, this.getClass().getClassLoader().getResource() and be sure you're with a "consistent" object (e.g. not in the constructor) – BigMike Jul 11 '12 at 07:29
  • @BigMike I tried your solution but the result is same. – Syed Muhammad Mubashir Jul 11 '12 at 07:37
  • 1
    post a jar tvf of your jar file please – BigMike Jul 11 '12 at 08:15
  • Please refer to this [example](http://stackoverflow.com/a/9583367/1057230), I hope that, resources folder is the `Source Folder` in your case. If this is the folder that you had added, then i guess you should be using `getClass().getResource("/NoPicture.png")` – nIcE cOw Jul 11 '12 at 08:19
  • Make sure the path is correct. And try to remove the `/` from the beginning of the path. – Radu Murzea Jul 11 '12 at 07:17

1 Answers1

0

Verify that your deployment JAR actually does contain the images :-)

Erich Schreiner
  • 2,038
  • 1
  • 14
  • 24