• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Loading Issues with Applet

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
mte01
Asked:
mte01
  • 5
  • 5
  • 5
  • +1
3 Solutions
 
objectsCommented:
split your jar such that all the resources that do not need to be availble at load time are in a seperate jar
0
 
mte01Author Commented:
>>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
 
CEHJCommented:
Don't include it in the applet tag but simply load it over the network using JarURLConnection
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
objectsCommented:
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
 
ebertkCommented:
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
 
mte01Author Commented:
>>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
 
objectsCommented:
> 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
 
objectsCommented:
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
 
mte01Author Commented:
>>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
 
mte01Author Commented:
>>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
 
mte01Author Commented:
I meant wouldn't having them in a jar to unpack them at runtime be faster?
0
 
CEHJCommented:
>>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
 
objectsCommented:
> 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
 
CEHJCommented:
>>and remember the download is only going to occur the first time the resource is needed.

(just said that)
0
 
CEHJCommented:
:-)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 5
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now