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 includes 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
<html> <body> <applet code="AnotherHello.class" width="300" height="150"> </applet> </body> </html>
This tells the browser to run the applet
and to use an area of the screen 300 pixels wide and 150 high.
To create this tiny Web page,
type the above characters into NotePad
(or copy and paste them into NotePad).
Then save the file as
in the same directory that has
At this point your directory should look something like this:
C:\> dir A*.* 03/07/98 08:01p 560 AnotherHello.class 03/07/98 08: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
Find the file with your file browser and double click on it.
Your default Web browser should start running and should display the applet.
Or you can use the appletviewer:
C:\> appletviewer AnotherHello.html
Sometimes browsers are not set up for applets,
or have other problems.
The appletviewer is in the same directory as
javac and is more reliable for viewing your applets
than a Web brower.
However, the appletviewer shows you only the applet part of an HTML file.
The other parts (if any) are omitted.