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!

Uncaught error fetching image: java.lang.NullPointerException

843807Sep 3 2009 — edited Sep 3 2009
Hi everybody,

I am developing standalone application using NetBeans,the aplication is running fine in netbeans IDE but not when Jar alone tried to run.I kept all the files related to application with the jar.

when running jar,the app is running fine upto some extent,and throwing exception at the time of fetching images from images folder which is placed inside "src folder"

class files package and images folder are in the src folder. the code is like this:
mLogo = new JLabel();
        URL lUrlLogo =  getClass().getResource("/images/eaze.gif");
        System.out.print(lUrlLogo);
        Image lLogoimage = Toolkit.getDefaultToolkit().createImage(lUrlLogo);//.getImage(lUrlLogo);
        ImageIcon licon = new ImageIcon(lLogoimage);
        mLogo.setIcon(licon);
i tried by using Mainclass.class.getResource("/images/eaze.gif");
and also by using thread but dint solved

The exception is like this:

Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:99)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:113)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 1 2009
Added on Sep 3 2009
1 comment
3,411 views