1

How do I change the default application icon in Java?

I tried the above code using Netbeans 7.0 but I'm not sure where the resources directory needs to be? If I use the one Netbeans has under files listing. It keeps giving me this error. Also, is the code correct?

Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:115)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:125)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)

using this code:

URL url;
url = ClassLoader.getSystemResource("/com/pbuddie/resources/Server.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
clientUI.setIconImage(img);
Community
  • 1
  • 1
JVasher
  • 11
  • 2
  • have you tried using the path `com/pbuddie/resources/Server.png` i.e. no leading `/` – Ali Aug 27 '11 at 15:46
  • Yeah, looks like you got a bad file path... double checking it might be in order. –  Aug 27 '11 at 15:56
  • I'm using the folder which is created by netbeans "resources" which is on the same lvl a dist folder. I'm not sure If i need to create a folder resources somewhere, if so where do i add it? I took the leading / off still didn't work.. Do the contents of that resource get moved into the jar.. or do I have to do something to make that happen.. – JVasher Aug 27 '11 at 17:49

0 Answers0