?
Solved

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

Posted on 1998-06-28
3
Medium Priority
?
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 880 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn different types of Android Layout and some basics of an Android App.
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 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