Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resource URLs broken in JWS



On Sep 30, 2008, at 5:16 PM, Michael Hall wrote:

To see if it makes any difference what does

ClassLoader mine = this.getClass().getClassLoader();
ClassLoader clazz = Toolbox.class.getClassLoader();
ClassLoader tb = new Toolbox().getClassLoader();

System.out.println("mine=" + mine + " class " + clazz + " Toolbox " + tb);

show. If 'this' is a Toolbox instance you could skip that. I'm assuming a no args constructor for that, but however you really get a instance.

Toolbox is an abstract class, so most of this won't work.
Running from a terminal, I get: class sun.misc.Launcher $AppClassLoader@92e78c.
Running from JWS, I get: class com.sun.jnlp.JNLPClassLoader@1cdeff.


I could try it on another class (com.bardac.dw1.tools.ui.SplashScreen) which isn't abstract - maybe tomorrow.


Greg Guerin wrote:

In general, I'd use the following, unless there's a good reason not to and you're taking a null ClassLoader possibility into account.

 rslt = this.getClass().getResource(name);


Using
URL url = SplashScreen.class.getResource("com/bardac/dw1/tools/ graphics/splash.jpg");
(with 1.5.0_16), I get:


[java] Uncaught error fetching image:
[java] java.lang.NullPointerException
[java] at sun.awt.image.URLImageSource.getConnection (URLImageSource.java:97)
[java] at sun.awt.image.URLImageSource.getDecoder (URLImageSource.java:106)
[java] at sun.awt.image.InputStreamImageSource.doFetch (InputStreamImageSource.java:240)
[java] at sun.awt.image.ImageFetcher.fetchloop (ImageFetcher.java:172)
[java] at sun.awt.image.ImageFetcher.run(ImageFetcher.java: 136)


whereas
URL url = SplashScreen.class.getClassLoader().getResource("com/ bardac/dw1/tools/graphics/splash.jpg");
works fine. Not sure why.



Thanks, Nick _______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: resource URLs broken in JWS (From: Nick Howes <email@hidden>)
 >Re: resource URLs broken in JWS (From: Michael Hall <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.