Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » imageicon(ImageIcon ii = new ImageIcon(this.getClass().getResource("/resources/star.png"));)
imageicon [message #938187] Tue, 09 October 2012 12:35 Go to next message
Alexandre Brabant is currently offline Alexandre Brabant
Messages: 5
Registered: October 2012
Junior Member
imageicon ii = new imageicon(this.getClass().getResource("/resources/star.png"));

It does not work and i don't understand why.

Exception in thread "main" java.lang.NullPointerException
at javax.swing.imageicon.<init>(imageicon.java:205)
at star.Board.<init>(Board.java:26)
at star.Star.<init>(Star.java:9)
at star.Star.main(Star.java:21)
Re: imageicon [message #938747 is a reply to message #938187] Wed, 10 October 2012 01:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25918
Registered: July 2009
Senior Member
Alexandre,

Where in your jar/folder is this file located? Is this for a plugin
project or just a regular Java project? If the latter, that folder
needs to be copied to the bin folder at development time because you've
specified that it belongs at the root of the jar (or the root of the
project's classpath folder).


On 09/10/2012 6:35 PM, Alexandre Brabant wrote:
> imageicon ii = new
> imageicon(this.getClass().getResource("/resources/star.png"));
>
> It does not work and i don't understand why.
>
> Exception in thread "main" java.lang.NullPointerException
> at javax.swing.imageicon.<init>(imageicon.java:205)
> at star.Board.<init>(Board.java:26)
> at star.Star.<init>(Star.java:9)
> at star.Star.main(Star.java:21)
Re: imageicon [message #939392 is a reply to message #938747] Wed, 10 October 2012 14:15 Go to previous message
Alexandre Brabant is currently offline Alexandre Brabant
Messages: 5
Registered: October 2012
Junior Member
Thank you, i put a copy of my resources folder in the bin folder and it works.
Thank you very mutch.
Previous Topic:Debug screen automatically scrolls while stepping
Next Topic:(Announce) Juno Chrome Theme supports Juno SR1 fully now.
Goto Forum:
  


Current Time: Thu Jul 24 21:47:58 EDT 2014

Powered by FUDForum. Page generated in 0.01465 seconds