java - Eclipse: code can't get imported image from package. Code works when read from C:/ -


when try make imageicon = new imageicon("source"); code doesn't read eclipse package want when tell read c:/... file works. why , how can fix it?

new imageicon("source") expecting file reference. resources maintained within application not (normally) considered files, instead, considered be, well, resources.

this means can't access them using "noraml" approaches might used to.

instead, try using getclass().getresource("/path/to/resource/source")

where path path top of source tree...


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -