Original Post
Hi, I would like to put all my icons into a separate jar file, and load them at run time. I was not able to get satisfiyng informations using google, so I'm asking to you guys for a help. What I know is: -Doing this should be pretty easy. -If the pictures were in the same package of the application, then using MyApp.class.getResource("path of the resource") should be enaught. With the obtained URL I should be able to create the icon in the following way: JButton e = new JButton(command, new ImageIcon(url)); -If the pics are in a different jar, the only requirement is that this jar lies in the classpath. My question are: how can I specify the classpath at runtime? If the pics jar is in the same directory of the app jar, shouldn't it be already in the classpath? Should the previous code work in this case? I'm using NetBeans 4.0 and if I run the app I get some exceptions: java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:138) at moneyflow.ToolBarPanel.addButton(ToolBarPanel.java:45) at moneyflow.MFGui.setUI(MFGui.java:69) at moneyflow.MFGui.<init>(MFGui.java:56) at moneyflow.Login$ActionHandler.actionPerformed(Login.java:145) . . . where the first line 'at javax.swing.ImageIcon.<init>(ImageIcon.java:138)' is the instruction: JButton e = new JButton(command, new ImageIcon(io)); Thank you all for the help