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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -