Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-06-28
3
Medium Priority
?
163 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

597 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