Solved

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

Posted on 1998-06-28
3
157 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

929 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

10 Experts available now in Live!

Get 1:1 Help Now