1

I have the following statement and it's giving me a Null pointer exception:

Icon settingIcon =
   GUIUtilities.loadIcon(
      context.getProperty( "sys.setting.icon.small" ));

I'm trying to debug it, but I'd like to know what the directory structure is like at the moment it's trying to find the property. Is it possible to find out where the compiler is searching through at the moment of the error?

Right now, I'm falling back to using (with default.png being at the root folder: /Users/bigbitecode/Documents/workspace/sys client_a/):

Icon saveIcon = new ImageIcon("default.png");

Some helpful information:

  • I have loaded the property successfully with the following info: at the file path: /Users/bigbitecode/Documents/workspace/sys client_a/sys-client/gui.prop
    #sys menu bar icon
    copa.setting.icon.small=icon/16x16/setting.png
  • The file I'm trying to get is located at: /Users/bigbitecode/Documents/workspace/sys client_a/sys-client/resources/icon/16x16/settings.png

  • The pathfile of the current code I have is at: /Users/bigbitecode/Documents/workspace/sys client_a/sys-client/src/sysClient/data/gui/sysClient.java

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
bigbitecode
  • 253
  • 5
  • 16
  • 1
    I hope you hadn't missed [this link](http://stackoverflow.com/a/11372350/1057230), from the links provided in the answer. – nIcE cOw Jun 18 '13 at 02:41

1 Answers1

3

By the time of deployment, those resources will likely become an . That being the case, the resource must be accessed by URL instead of File. See the info page for the tag, for a way to form an URL.

The likely path needed for getResource() is /icon/16x16/settings.png

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • I must be doing something wrong. I tried referencing the resources with getResource, but I seem to always be hitting at a null with the following code: URL url = this.getClass().getResource("/resources/icon/16x16/settings.png"); Icon openFileIcon = new ImageIcon(url); – bigbitecode Jun 17 '13 at 19:26
  • Do a `jar -tvf the.jar` to confirm it is where you expect. – Andrew Thompson Jun 18 '13 at 02:02
  • I did a grep, and noticed that settings.png was not included. What does this mean? I have it all inside the resource folder, but it doesn't show up on the final .jar. Is there a way to include all the images? – bigbitecode Jun 18 '13 at 04:37
  • *"I have it all inside the resource folder,"* You seem to presume I know a lot about your IDE & build environment, that I actually don't. Tip: At times like this, more detail is better than less. ;) – Andrew Thompson Jun 18 '13 at 04:41