A First Java Program
We start by writing what is called
a Java applet. This is a form of a Java program that
can be embedded in a HTML document and accessed from the
web. An example HTML document that calls our example applet is
shown below:
<HTML>
<HEAD>
<TITLE>Demo Applet</TITLE>
</HEAD>
<BODY>
<H1>Demo Applet</H1>
<P>My favorite class is 6.837</P>
<HR>
<CENTER>
<APPLET code="Demo.class" width=200 height=200>
</APPLET>
</CENTER>
<HR>
</BODY>
</HTML>
The highlighted lines add the Java code to
our document. Notice the .class extension. All Java source
code files should end with a .java
extension. The source is here.
|