IT Community - Software Programming, Web Development and Technical Support

Why it shows like "Unknown Source" for Invalid Path?

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( ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-12-2007, 12:27 AM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 324
amansundar is on a distinguished road
Question Why it shows like "Unknown Source" for Invalid Path?

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-13-2007, 01:07 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Smile Re: Why it shows like "Unknown Source" for Invalid Path?

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!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-21-2007, 11:06 PM
amansundar amansundar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 324
amansundar is on a distinguished road
Default Re: Why it shows like "Unknown Source" for Invalid Path?

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
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -7. The time now is 08:06 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0