Building an Applet

To build an applet, you need to have the SDK installed. After that's done, you'll follow a four-step process.

To build a Java application:

  1. Enter the code into a text file.

  2. Compile all classes by using javac.

  3. Write an HTML file that loads the applet.

  4. Load the HTML file by using your Web browser.

This section covers the first two steps. The next section, "Running the Applet," describes the last two steps.

Writing the Code

Use any text editor to make a program source file, as shown in Listing 36.1. Complete source code for each of these programs is included on the Web site.

Code Listing 36.1. HelloApplet.java—Start by Importing Sun's Classes
 import java.applet.Applet; import java.awt.Graphics; public class HelloApplet extends Applet ...

Get Platinum Edition Using XHTML™, XML, and Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.