It’s worth noting that so far you have followed exactly the same steps as you would if you were creating a Java application. The applet has been created and saved in a text file, and it has been compiled by the javac compiler.
Java Applets differ from Java applications when it comes to running them. What’s needed now is a web page that references the FirstApplet.class file. Remember, the class file is the compiled version of your applet; this is the file your computer can understand and execute.
Open up Notepad, and type in the following HTML code:
<HTML>
<HEAD>
<TITLE>My First Java Applet</TITLE>
</HEAD>
<BODY>
Here's my first Java Applet: <BR><BR>
<applet code="FirstApplet.class" width="300" height ="300">
</BODY>
</HTML>
Save the file as “MyWebpage.html” in the same directory as your Java applet files.
This is the most important line in the webpage:
<applet code="FirstApplet.class" width="300" height ="300">
When the web page is displayed, it tells the browser to open up your Java applet and run it.


