Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

getClass().getResource() error from jar file.

843805Jan 19 2007 — edited Mar 2 2007
I am using getClass().getResource("../images/image.gif") to refer to a resource and load it into the ImageIcon. So that my resource's url is dynamic and be got at runtime. It is working fine when I run my program, but when I exported my application into a jar file then while trying to execute the jar file using the
java -jar program.jar command it is giving the following error (Stack trace)
Exception in thread "main" java.lang.NullPointerException
        at javax.swing.ImageIcon.<init>(ImageIcon.java:138)
        at source.HashCalculator.<init>(HashCalculator.java:130)
        at source.HashCalculator.main(HashCalculator.java:2021)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2007
Added on Jan 19 2007
14 comments
1,443 views