Solved

Fast loading of an applet

Posted on 1997-07-18
6
206 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 98
object oriented programming comparison 5 72
Java string replace 11 48
mysql jsp example issue 32 38
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

803 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