Here is a very simple applet:

Here is the html used above to include the applet:

<APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25></APPLET>

Here is the source code, the contents of the file

import java.applet.Applet;
import java.awt.Graphics;

public class HelloWorld extends Applet {
   public void paint(Graphics g) {
	   g.drawString("Hello world!", 50, 25);
You can see how specifying that the text be drawn with baseline at 25 is a bad idea if the space given to the applet is only 25 pixels!

The upper left corner is (0,0), so (50,25) is one pixel out of bounds!

"javac" compiles it, producing the file HelloWorld.class which is included by the above html.