My program has the following lines, works fine when run from Netbeans,
JButton Button_1=new JButton(new ImageIcon(Phone_Dialer.class.getResource("Dir_Icons/"+"Key_1"+Botton_Color+".gif")));
But when I run it from the resulting Jar file, this line caused "java.lang.NullPointerException" error, why ?
The dir is like this :
C:Phone_DialersrcPhone_Dialer.java
C:Phone_DialersrcDir_IconsKey_1_Silver.gif
C:Phone_DialerdistPhone_Dialer.jar
===========================================================================================
It s definitely not the "Botton_Color" problem, It s a string like this : "Silver" or "Pink", so if I change the above line to "Dir_IconsKey_1_Silver.gif
", it still works fine in the IDE while not be able to run from an executable Jar file, the problem seems to be : Why after jar the project, it can t find the resources. The Jar file was generated by Netbeans, and is executable.