Solved

Non-Java-Classes and Java Package Manager (IE4.0)

Posted on 1998-06-28
3
156 Views
Last Modified: 2010-04-16
I have installed classes in IE4's memory using the Java Package Manager.  (JPM)  Now I need access to the gifs (and other non-class files) that are in the same cab file as the OSD. Can anyone help?  I want this to act as a completely dynamic classloader without having to touch the user's CLASSPATH or download the "non-JAVA-class" files to their hardrive.  (My applet is already certified and is trusted)
 
0
Comment
Question by:smithcb
3 Comments
 
LVL 6

Expert Comment

by:gadio
ID: 1224065
smithcb, I think that when you pack your code in a jar file the IE4 puts all the files in the jar in its cache and any url that you may open to a resource, is actually taken from the cache. I would expect the same behavior when working with cab files. Give it a try. You can wait some time before loading a gif (hopefully from the cab) and in the delay time - disconnect you machine from the net, and see if the gif comes up.
0
 
LVL 5

Accepted Solution

by:
fontaine earned 220 total points
ID: 1224066
If I understand well the question, you ask how to load an Image, for example, that comes
bundled in an archive. I show you how to do that for an Image. For other kinds of data,
things are similar.

Here are two options:

URL imgURL = getClass().getResource("theImage.gif");
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = null;
try {
 image = toolkit .getImage(imgURL);
 }
catch (Exception e) {
 e.printStackTrace();
 }

With some browsers, you can't use getResource() but getResourceAsStream() is supported: :

try {
 InputStream in = getClass().getResourceAsStream("theImage.gif");
 BufferedInputStream bufIn = new BufferedInputStream(in);
 byte[] bytes = new byte[10000];
 int byteRead = bufIn.read(bytes,0,10000); // assuming that the image is < 10000 bytes
 image = Toolkit.getDefaultToolkit().createImage(bytes,0,byteRead);
 }
catch(Exception e) {
 e.printStackTrace();
 }
0
 

Author Comment

by:smithcb
ID: 1224067
Sorry it took me so long to come back to you to award your points.  In the end I figured it out as you explained.  You are exactly correct...

Thanks so much.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now