This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes Getting non-Java resources from cache jars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Getting non-Java resources from cache jars" Watch "Getting non-Java resources from cache jars" New topic
Author

Getting non-Java resources from cache jars

Pete Ihlenfeldt
Greenhorn

Joined: Jan 24, 2008
Posts: 9
I don't completely understand the Dark Arts of how the plugin facilitates the connection between an applet and the jars in the plugin cache... making them part of the applet's classpath. But i do know that with all the auxiliary jars I have, the applet has been finding the classes it needs.

Now I have a rather large spreadsheet, that I wanted to deploy as an uncompressed jar, because it takes too long to stream it over the wire off the server. I wanted to avoid putting the spreadsheet in the applet jar itself. So, I did a jar cvf0, put the spreadsheet in there, included it in my project classpath (e.g. project properties -> compile -> libraries -> add new Jar).

Locally it works great.



works perfect.

For the applet, I added an entry in the <OBJECT> tag on the serving HTML page, and deployed. When I start the applet, the plugin retrieves the file perfectly, and I checked it in the cache... all good.

Problem: getSystemResourceAsStream returns null.

I am moderately experienced with the other Dark Arts of ClassLoaders, but does anyone see a glaring, obvious blunder I am committing?
[ January 29, 2008: Message edited by: Pete Ihlenfeldt ]
Pete Ihlenfeldt
Greenhorn

Joined: Jan 24, 2008
Posts: 9
The answer: for anyone who needs it:

I read some tech notes and found that the proper way to do this is NOT to use getSystemResourceAsStream. Rather you should use "getResource".

Obviously you would re-arrange this code with the proper try/catch/finally blocks, but the condensed form is:



hope this helps someone.
[ February 05, 2008: Message edited by: Pete Ihlenfeldt ]
 
jQuery in Action, 2nd edition
 
subject: Getting non-Java resources from cache jars
 
Similar Threads
How to have my own log4j.xml file in Jboss
disk cache for JAR files when running plugin
Clearing the applet cache through code
Archive problem.
Applet downloading server copy of jars already cached