This is a discussion on Why it shows like "Unknown Source" for Invalid Path? within the Java Programming forums, part of the Software Development category; I keep my images in a jarfile and load them as followes: Image image = null; try { image = Toolkit.getDefaultToolkit().getImage( ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| I keep my images in a jarfile and load them as followes: Image image = null; try { image = Toolkit.getDefaultToolkit().getImage( url ); } catch ( Exception e ) { // inform user. } This works fine, but when i accidently misspell the image name I get: java.lang.IllegalStateException: zip file closed at java.util.zip.ZipFile.ensureOpen(Unknown Source) at java.util.zip.ZipFile.getEntry(Unknown Source) at java.util.jar.JarFile.getEntry(Unknown Source) at com.sun.deploy.cache.CachedJarFile.getEntry(Unknow n Source) at sun.net.http://www.protocol.jar.JarURLConnec...onnect(Unknown Source) at sun.plugin.net.protocol.jar.CachedJarURLConnection .connect(Unknown Source) at sun.plugin.net.protocol.jar.CachedJarURLConnection .getInputStream(Unknown Source) at sun.awt.image.URLImageSource.getDecoder(Unknown Source) at sun.awt.image.InputStreamImageSource.doFetch(Unkno wn Source) at sun.awt.image.ImageFetcher.fetchloop(Unknown Source) at sun.awt.image.ImageFetcher.run(Unknown Source) Why isn't the exception caught?
__________________ cheers Aman |
| Sponsored Links |
| |||
| Because the operation is not executed on the same thread, and therefore the exception isn't, either. AFAIK, this is to prevent clogging up the EDT. If you wish to load images in the same thread, consider using ClassLoader or the javax.imageio package.
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
| |||
| Hi Vinoth! thnx for spending your time to me... I noticed later that class ImageIcon indeed waits for that thread to finish using MediaTracker. But shouldn't method getImage() not FIRST check the presence of the image BEFORE starting the thread to load it? And the problem does not only occur with images, any file in the jar has the same problem. And why is there no problem when the URL is referring to an image folder at the host? The unknown image simply isn't loaded then, but the program continues normally.
__________________ cheers Aman |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can I hide the JavaScript source code from "view source" function of the browser? | KiruthikaSambandam | HTML, CSS and Javascript Coding Techniques | 1 | 11-13-2007 09:17 PM |
| I keep getting "Data Missing" when I click the "back" button in my browser. How can I | oxygen | HTML, CSS and Javascript Coding Techniques | 1 | 07-28-2007 01:12 AM |
| Diffrence between a "assignment operator" and a "copy constructor" | Sabari | C and C++ Programming | 1 | 07-24-2007 05:00 AM |
| Why do I get "HTTP 500" error(or "(DLL)initialization routine failed")in my browser? | kingmaker | ASP and ASP.NET Programming | 1 | 07-20-2007 04:38 AM |
| Difference between a "assignment operator" and a "copy constructor"? | vigneshgets | C and C++ Programming | 2 | 07-12-2007 05:30 AM |