Solved

Loading Issues with Applet

Posted on 2007-11-15
16
214 Views
Last Modified: 2012-05-05
I have a jar file (that contains resource files) that I am loading with an applet (in a php page) using the ARCHIVE tag; the problem is that the applet is taking too much time to load since the size of the jar file is large; now, since I don't need these resource files in the jar until after the applet loads; is there any way in which I can load the jar upon a certain event in the applet (paint method or something like it)?? any help on any alternative method (that would decrease load time) would be also appreciated
0
Comment
Question by:mte01
[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
  • 5
  • 5
  • 5
  • +1
16 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20293591
split your jar such that all the resources that do not need to be availble at load time are in a seperate jar
0
 
LVL 3

Author Comment

by:mte01
ID: 20294006
>>objects

Ok; that was the plan, but how do we load that jar at runtime as the applet is running (or after the applet has completed loading)?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20294506
Don't include it in the applet tag but simply load it over the network using JarURLConnection
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 20294517
0
 
LVL 92

Assisted Solution

by:objects
objects earned 190 total points
ID: 20294616
if you jar isn't in the archive tag then it won't get loaded.
If you want to load individual resources as you need them then don't jar them and instead make then directly availoable from applet codebase. That way they'll get downloaded when needed (and you won't have to wait for them *all* to be downloaded). If you can afford to wait for them all in one hit then load the jar at the point you need it.
0
 
LVL 5

Assisted Solution

by:ebertk
ebertk earned 80 total points
ID: 20296205
Objects is correct - but to be clear, you will need to have all of the resources in their uncompressed format.  This probably isn't an issue with images (and would work just fine)  but it could be a problem with the class files that are used by the applet.  Since most class files are often part of packages, if you don't put them in a jar, the packages need to be subdirectories on your server.  This can be a real mess (for example if you have a packge com.kje.stuff, with serveral classes in it, you would need to have the directory structure com/kje/stuff on the server to contain the classes.

So I would recommend that you put all of your class files into a Jar, and then leave all of the images and other resources outside the jar.  All of your class files would load when the applet starts up, but none of the images, etc.  These items should then load as they are needed.
0
 
LVL 3

Author Comment

by:mte01
ID: 20296960
>>ebrtek

Yes, the resource files are separately in a jar file

>>objects,CEHJ

I am experimenting right now with both of your methods. Since there are a large number of small images (around 300), I want to try not load them each via a direct URL, I want to load them all in a jar file, but I don't want it to load at startup; I want to load it at some time after the applet has already started, so I guess CEHJ's suggestion of using JarURLConnection should be the solution to my problem - the only thing I am trying right now is to see if I can access the resources normally when using this class in the same way as when they are loaded in the ARCHIVE tag
0
 
LVL 92

Expert Comment

by:objects
ID: 20297009
> I want to try not load them each via a direct URL

why exactly do u want to avoid it?

> the only thing I am trying right now is to see if I can access the resources normally when using this class in the same way as when they are loaded in the ARCHIVE tag

you can't
0
 
LVL 92

Expert Comment

by:objects
ID: 20297027
a seperate class loader would be a better way to load them.
will dig around for some old code we had for doing what it is you are trying.
0
 
LVL 3

Author Comment

by:mte01
ID: 20297729
>>objects
>>will dig around for some old code we had for doing what it is you are trying

Many thanks!..I will really really appreciate this!...
0
 
LVL 3

Author Comment

by:mte01
ID: 20319765
>>objects

Ok; I did it by using a direct url, but now I have in a certain page 330 separate http requests to retrieve images; I think this is madness; what do you think? Wouldn't having them in a jar to unpack them at runtime be easier
0
 
LVL 3

Author Comment

by:mte01
ID: 20319769
I meant wouldn't having them in a jar to unpack them at runtime be faster?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20321950
>>the problem is that the applet is taking too much time to load since the size of the jar file is large;

Most of the time is actually occupied by loading the runtime. After the jar has been loaded once, it will be got from cache anyway.

If you remove the jar in question entirely, do you notice much difference? Obviously start from the POV of a completely empty cache
0
 
LVL 92

Expert Comment

by:objects
ID: 20323155
> Wouldn't having them in a jar to unpack them at runtime be easier

depends on your needs, if you can afford the delay of a bigger download then yes.

and remember the download is only going to occur the first time the resource is needed.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20323241
>>and remember the download is only going to occur the first time the resource is needed.

(just said that)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 20402035
:-)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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