Solved

Fast loading of an applet

Posted on 1997-07-18
6
202 Views
Last Modified: 2012-06-22
I have an applet which has a lot of classes (about 100) in it. When the html page (which contains the applet) is loaded, it takes a long time for the first window to come up because it is trying to load all the classes for that applet, before showing the window. Is there some way by which the first window can come up quickly and in the background I load rest of the classes that are needed for the applet.

Also if i zip up the classes, which zip utility should i use so that the zip file works both win MS IE 3.01 and Netscape 3.01.
0
Comment
Question by:vmanocha
  • 3
  • 3
6 Comments
 

Accepted Solution

by:
cromero earned 50 total points
ID: 1223389
You must modify the applet tag in the following way:

<APPLET
  CODE=MyMainClass.class
  WIDTH=nnn
  HEIGHT=nnn
  CODEBASE=.
  ARCHIVE="MyClassesAndMyPackages.zip">
</APPLET>

"codebase=." when all the stuff is in the same directory than the html page. The zip archive "MyClassesAndMyPackages.zip" must contain also the main archive "MyMainClass.class" and all the archives _m_u_s_t_ be packed with no compression. Also they must be packed recursing folders containing classes if you are working with your own packages.

This works only with Netscape Browsers. MS I. Explorer don't understand zip package but MS own format "cabinet".

When your cabinet file is done, for instance, MyClassesAndMyPackages.cab, you must add the tag

<PARAM NAME="CABBASE" VALUE="MyClassesAndMyPackages.cab">

between <APPLET...> and </APPLET>. Then IE is able to understand the code as Netscape is.

You may check out the Microsoft Java developer documentation.

I apologise por my very poor English. Good luck!

Carles Romero, cromero@pie.xtec.es
0
 
LVL 1

Author Comment

by:vmanocha
ID: 1223390
You did not mention anything regarding my query for loading the applet in the background ???


0
 

Expert Comment

by:cromero
ID: 1223391
Well. In the approximation I propose you classes are loaded faster because they travel across the net using a single connection. Without packing class files, they need a particular connection with the server for each of them and this consumes a lot of time...
If you wish to load the other than main class in the background I think you must not pack them anyway but your main class must be very simple and waiting for some event (a button push, for instance) which will fire class loading.

Yours...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:vmanocha
ID: 1223392
Can you please elaborate on the how will i load the classes inside the applet ? Some sample code will be very helpful.

And also if i put the classes in zip/cab format, how do i make sure that my applet will work will at least with both Netscape (> 3.x) and MS IE (> 3.x) since Netscape can only understand zip and MSIE can only understand cab ?
0
 

Expert Comment

by:cromero
ID: 1223393
Answer to 1st question:
It may look very silly but I think it will work:

class Main extends Applet {
  public void init () {
    //some stuff about layouts, colors, etc. of this first window
    ...
    ...
    Button initButton=new Button("Click here!");
    add(initButton);
  }
  public boolean Action (Event e) {
    // On click over initButton launch the program
    // In this moment class loading begins...
    // You may add a label looking like "Please be patient..." :)
  }
}

Answer to 2nd question:
The HTML code:
<APPLET
 CODE=MyMainClass.class
 WIDTH=nnn
 HEIGHT=nnn
 CODEBASE=.
 ARCHIVE="MyClassesAndMyPackages.zip">
 
 <PARAM NAME="CABBASE" VALUE="MyClassesAndMyPackages.cab">

</APPLET>

will be understood for _b_o_t_h_ Netscape Navigator and MS Internet Explorer.

Yours...
0
 
LVL 1

Author Comment

by:vmanocha
ID: 1223394
thanks for the explanation. but it is still not exactly what i wanted. as far as the second part goes, that is clear. regarding the first part of the question (class loading), i am not clear as to how to load classes in an applet.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JAVA part two 5 57
Groovy:unable to resolve class error 2 69
Where to store the queries for modification of table 4 55
tomcat not starting 6 30
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…
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…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

911 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

16 Experts available now in Live!

Get 1:1 Help Now