Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Java Tip 28: Improve your applet's download performance using Navigator's Java console

Here's how to optimize your zip file components to achieve quicker applet startup

You've probably already read about packaging your applet using zip files to improve download performance in Netscape Navigator (see Java Tip 21: Use archive files to speed up applet loading). But in certain situations, using zip files for applets can lead to performance problems.

For example, let's say a tools vendor has created a general package that includes a number of features -- many of which you probably won't use. Including all of these classes in your zip file will cause it to quickly grow from a few kilobytes to hundreds of kilobytes or more, thus negating the reason to use a zip file in the first place.

There is a solution to this problem. Although undocumented, the Netscape Navigator browser contains a Java console (under the Options menu). When this console is open, messages appear that are written to System.out.println from whatever Java applets happen to be running in your browser.

What your mother didn't tell you about the Java console

What isn't obvious to users is that the Java console accepts keyboard commands. There are 10 debugging "levels" (as the message displayed by the browser labels them) and 3 other keyboard commands in Navigator 3.0. Pressing the keys 0, 1, 2, ..., 9 sets the debugging-level information that the virtual machine will display. Pressing the keys D, F, and G will cause other actions, as described below. In Netscape Communicator 4.0, several more commands have been added, including a help command describing the keys that are valid as commands. If you press the "h" key you will get documentation for the new commands.

This tip presents everything I know about using keyboard commands in the Java console: I haven't been able to find any documentation about it. Perhaps my findings will encourage someone at Netscape to document the debugging levels and the three other keyboard commands.

Know your way around the keyboard commands

Following is a description of the D, F, and G keystroke actions:

  • The "D" keystroke causes the Java console to display information about all the applets loaded by the virtual machine in the current Netscape session. Multiple copies of the Netscape browser that are open at the same time share the same Java console.

  • The "F" keystroke causes the Finalize clauses of discarded, yet not garbage-collected, memory to be run -- at least I think this is what happens, as a separate key exists for garbage collection.

  • The "G" keystroke causes the Runtime.gc() garbage collector to run. I have played a little with the garbage collector, and I believe many calls must be made to it in order to clean up memory. Minimizing the time taken to call the garbage collector makes sense because objects are linked to other objects. If the garbage collector only unlinks objects at the ends of another object each time, it can step through the heap in stages. This means the garbage collector doesn't spend a lot of valuable time at each stage but uses many small chunks of time when the CPU would otherwise be unused.


Here is the output that's displayed in the Java console window when each of the keys described above is pressed. A copyright message from the browser precedes the keyboard command output: "AppAccelerator(tm) 1.0.2a for Java, x86 version. Copyright (c) 1996 Borland International. All Rights Reserved."

1 | 2 | 3 |  Next >
Resources