Solved

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

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 video teaches viewers about errors in exception handling.

695 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