[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

Fast loading of an applet

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
vmanocha
Asked:
vmanocha
  • 3
  • 3
1 Solution
 
cromeroCommented:
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
 
vmanochaAuthor Commented:
You did not mention anything regarding my query for loading the applet in the background ???


0
 
cromeroCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
vmanochaAuthor Commented:
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
 
cromeroCommented:
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
 
vmanochaAuthor Commented:
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

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now