Java Reference
In-Depth Information
Again, your applet should compile successfully at this point. If it doesn't,
review the previous suggestions.
Applets are meant to be executed in a hosting environment, often a Web
browser. Web browsers display information in HTML documents and are
instructed to execute applets by special commands in the HTML docu-
ment. The HTML command to execute an applet is the <applet> tag. This
tag instructs the browser to run the applet specified in the applet tag.
You do not need to be an HTML expert for this step, but you will need to
create a simple HTML document.
5. Using a text editor, create an HTML document named HelloWorld.html in
your applet directory. The file should contain these statements:
<html>
<head>
<title>HelloWorld</title>
</head>
<body>
<hr>
<applet
code=HelloWorld
width=200
height=200>
</applet>
<hr>
</body>
</html>
Remember to save this file under the name HelloWorld.html, and to save
it as a text file, not as a document.
6. In the DOS command window, execute the APPLETVIEWER program to
display your applet. Make sure you are in the applet directory.
appletviewer HelloWorld.html
If you've done everything correctly, your MS-DOS window and your ap-
plet viewer window should look like Figure 2.3.
Search WWH ::




Custom Search