Compiling and Running an Applet by Charles W. Neville, 1998 Copyright Charles W. Neville, 1998 Applets are designed to be run through a Web browser. Web browsers understand HTML (HyperText Markup Language) so to run an applet you have written, you have to carry out the following steps. 1. Save the applet in a file with THE SAME NAME as the class and a .java extension. For example, the HelloApplet applet begins with public class HelloApplet extends Applet { so you would save the applet text in a file named HelloApplet.java. (No period at the end.) 2. Compile the applet by typing javac and the class file name. For example, the HelloApplet applet would be compiled by typing javac HelloApplet.java 3. Write a simple HTML file for the Web browser. For the HelloApplet applet, the HTML file might look like this: Save the HTML file with a .html extension. For the HelloApplet applet, you would save the file as HelloApplet.html. (No period at the end.) 4. Run your applet through a Web browser. Because most Web browsers, including all but the very most recent versions of Netscape Navigator and Microsoft Explorer, do not fully implement Java version 1.1, you should use Sun's appletviewer. For the HelloApplet applet, you would type appletviewer HelloApplet.html 5. Enjoy watching your applet run.