making new symbol from two symbols Why cast an A-lister for Groot? try this: Toolkit.getDefaultToolkit().getImage(imageURL) Go to Solution 4 Comments LVL 92 Overall: Level 92 Java 88 Message Expert Comment by:objects2006-01-09 looks like it cannot find your image where is the image Jar the application (together with it's resources) share|improve this answer answered Jul 26 '12 at 2:15 MadProgrammer 252k15101199 Ok so my image is not complied with the rest of froggyswampJune 28th, 2009, 12:36 PMFor a simple deployment where the classes and the image (and other) resources are located in known locations relative to one another, the getResource() approach will be weblink
C:\hw\myProg\Graphics2d\. Browse other questions tagged java image jframe or ask your own question. But when I run the code as a jar or through a bash file, it can't find the image (when loaded as a file instead of getResource()); thanks, bp froggyswampJune 28th, Join them; it only takes a minute: Sign up Cannot display icon - Uncaught error when fetching image up vote 1 down vote favorite I want to display another icon instead http://stackoverflow.com/questions/10681257/error-uncaught-error-fetching-image-java-lang-nullpointerexception
Show 1 reply 1. Why is C# Dim a Chord in B Minor? How to fix a bent lens mount hook? Nor can you catch the exception yourself and mitigate the problem. –Troyseph Oct 21 '14 at 14:56 add a comment| up vote 1 down vote I find the best way to
Login. Covered by US Patent. One of the parameters in the contructor is the path to the image file. Ie what is printed with System.out.println(this.getClass().getResource("")); lib/images/etc is being resolved relative to that location.
Debug yourself: let it print (show as a GUI alert) the URL when running from a .jar file and when running "as usual". Calendar Must Display E Need Help With Java Amortization CodeNeed Help With Java Amortization Code Help On An Employee Clas With Inheritance - I Need Help With Some Parts Of This Java Flight Recorder is a profiling and event collectioâ€¦ Java Singleton Design Pattern Video by: Amitkumar The viewer will learn how to implement Singleton Design Pattern in Java. Why does Wikipedia list an improper pronunciation of Esperanto?
Get 1:1 Help Now Advertise Here Enjoyed your answer? https://community.oracle.com/thread/1354032?start=0 What do you call someone without a nationality? Re: Uncaught error fetching image: java.lang.NullPointerException kloeber Sep 3, 2009 2:15 PM (in response to 843807) don't specify an absolute path line "/images/eaze.gif" but use a relative path like "images/eaze.gif" or Note you dont need to declare the other classes as public if you are puting them in the same page like you did in line 216: public class Inventory5i extends JFrame
All rights reserved. have a peek at these guys When you use Class.getResource, the call will begin the search from the location of the class, i.e the package where the calling class is located. Uncaught error fetching image: java.lang.NullPointerException at sun.awt.image.URLImageSource.getConnection(Unknown Source) at sun.awt.image.URLImageSource.getDecoder(Unknown Source) at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source) at sun.awt.image.ImageFetcher.fetchloop(Unknown Source) at sun.awt.image.ImageFetcher.run(Unknown Source) naturally my image file is in C:\hw\myProg\Graphics2d\Castle.jpg So what am I You need to debug the variables which were used around the time that your own code appears for the first time in the stacktrace.
So you're intuition was correct, initially just using "house.png" as the path, as the image is at the root. I using eclipse I did more homework on it but it showed things complied when they put in the scr folder but that did not work for me. –user1553246 Jul 26 Then you'll find the line of code where you have a null reference which causes trouble. (or set the breakpoint on the line of code that is printed on the stack check over here PLEASE stop me from yanking my hair.
Files in src/main/resources become resources on the class path. URL test = DrawImage.class.getResource("/"); System.out.println(test); java image jframe share|improve this question edited Jul 26 '12 at 15:26 asked Jul 26 '12 at 1:55 user1553246 313 add a comment| 1 Answer 1 Solutions?
share|improve this answer answered Jan 7 '10 at 14:58 lorenzog 1,7841928 add a comment| up vote 0 down vote the question is already answered, but I would suggested two additional changes Dealing with a nasty recruiter What is way to eat rice with hands in front of westerners such that it doesn't appear to be yucky? How to create a torus with divided cuts that correspond to the direction of the torus Dealing with a nasty recruiter How do we play with irregular attendance? 2011 MacBook Pro Hilbert-irreducible Banach space Given that ice is less dense than water, why doesn't it sit completely atop water (rather than slightly submerged)?
It may also help to look at the javadoc for getResource. Join them; it only takes a minute: Sign up error : Uncaught error fetching image: java.lang.NullPointerException up vote 0 down vote favorite The image path is all correct only, I don't Or can I import the image folder into eclipse? this content It is a shame the error isn't a bit more descriptive.
Big difference! So for instance if you have something like src main resources house.png main java com mypackage CallingClass.class The search will being in com/mypackage. bp badpersonJune 30th, 2009, 08:15 PMfixed it...I needed to move the folder that held the images under the "src" folder in eclipse.