Solved

Fast loading of an applet

Posted on 1997-07-18
6
208 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
even odd program using while loop 3 60
servlet example 17 51
JavaFX TableView not displaying correctly 3 57
collection output issue 9 37
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

828 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