Skip to main content


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 16:35 Go to next message
Alexandre Brabant is currently offline Alexandre BrabantFriend
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 05:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: imageicon [message #939392 is a reply to message #938747] Wed, 10 October 2012 18:15 Go to previous message
Alexandre Brabant is currently offline Alexandre BrabantFriend
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: Fri Apr 19 22:53:31 GMT 2024

Powered by FUDForum. Page generated in 0.08124 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top