Solved

Loading Issues with Applet

Posted on 2007-11-15
16
180 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
firstChar challenge 13 86
Java passing arguments (type error) 2 35
eclipse formatting 6 43
mockito example issue 8 38
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
The viewer will learn how to implement Singleton Design Pattern in Java.
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 …

746 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