java - ImageIcon exception -


im new java, , while running on eclipse linux mint java-7-openjdk (i think , although dont know if eclipse has own sun jdt),

public class gui extends jframe{ private jcombobox box; private jlabel picture; private static string[] filename = {"b.png","x.png"}; private icon[] pics = {new imageicon(getclass().getresource(filename[0])),        new imageicon(getclass().getresource(filename[1]))};    exception in thread "main" java.lang.nullpointerexception @ javax.swing.imageicon.<init>(imageicon.java:205) @ bucky.gui.<init>(gui.java:10) @ bucky.apples.main(apples.java:12) 

i cant see problem (linux mint 15 cinnamon)

this exception thrown in imageicon constructor , states getclass().getresource(filename[0]) or getclass().getresource(filename[1]) null

the path specified isn't correct. make sure folder these images in classpath

an easy check can made:

file f = new file("b.png"); system.out.println(f.exists()); 

should print true


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -