Applets are not stand-alone objects, and only run in the context of a larger program (such as a browser.)
To run an applet, you need a web page that asks for it. A web page is a text file that can be displayed by a web browser. Here is a tiny web page that asks for the applet AnotherHello.class:
<html> <body> <applet code="AnotherHello.class" width=300 height=150> </applet> </body> </html>
To create a tiny web page,
type the above characters into NotePad (or, more
sensibly, copy and paste them into NotePad).
Then save the file as AnotherHello.html
in the same directory that has AnotherHello.class
.
The part of this "html" file that asks for an applet
is this:
<applet code="AnotherHello.class" width=300 height=150> </applet>
This tells the browser to run the applet AnotherHello.class
,
and to use an area of the screen 300 pixels wide and 150 high.
At this point your directory should look something like this:
C:\> dir A*.* 03/07/98 08:01p 560 AnotherHello.class 03/07/98 09:01p 199 AnotherHello.html 03/07/98 08:00p 247 AnotherHello.java 3 File(s) 1,006 bytes 157,295,104 bytes free
Now you can use your web browser to look at AnotherHello.html. Or you can use the appletviewer of the Java Development Kit:
C:\> appletviewer AnotherHello.html
The appletviewer will just show you the applet part of the ".html" file.