Previous Next Contents

6. Viewing Applets

To run a demo without going through the applet viewer, you can enter this command from the top of my Java directory tree (/usr/local/java on most systems):

bin/java sun.applet.AppletViewer demo/<directory_name>/exampleN.html

where <directory name> is the subdirectory off demo, and N is the number of the example file (some directories have more than one).

Steve Greene says: I've started the tutorials available from Sun's java site and the similar one put out by the NTMUG. I've discovered some problems with the syntax in Sun's tutorial, so I've been following the NYMUG tutorial instead for now.

The appletviewer expects as an argument, an html file with an APPLET tag inside it.

For example, if your html file Hello.html looks like:

   <HTML>
   <HEAD>
   <TITLE> Hello test program </TITLE>
   < /HEAD>
   <BODY>
   This is an appletviewer test
   <APPLET CODE="Hello1.class" WIDTH=150 HEIGHT=25>
   < /APPLET>
   < /BODY>
   < /HTML>
(If you see "< /" in the above, ignore the space. It's a workaround for a formatter bug.)

Running "appletviewer Hello.html" will show you the applet. One advantage of using the appletviewer is that events sent to the applet (start(), init(), etc) are in compliance with Sun specs as opposed to Netscape 2.0b4 (probably a bug in Netscape).

A disadvantage of using the appletviewer is that it is much more slower than Netscape.

The first time you run Java, a license screen resembling Netscape's will be displayed.


Previous Next Contents