Solved

Loading Issues with Applet

Posted on 2007-11-15
16
209 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

726 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