| Copy this source code and save it to a file called Hello.java (note the capital H) |
/* Hello World Applet */
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
public class Hello extends java.applet.Applet {
Font f = new java.awt.Font("TimesRoman",Font.BOLD,36);
public void paint(Graphics g) {
g.setFont(f);
g.setColor(Color.red);
g.drawString("Hello World!", 5, 50);
}
}
|
If you would like to see the code for the "Hello World" applet click here and, if you like, copy the contents of the screen that loads in your browser , paste it in a text editor and save it in a file called "Hello.java".
Once you have saved the Hello.java file you need to compile the intermediate code.
At a DOS prompt type the following
JAVAC Hello.java
The JAVAC is the name of the compiler. It can be in lower or upper case. But the Hello.java Must have an upper case H and all lower case letters after that. This is dictated by the fifth line of code that tells the compiler that we are creating an applet called Hello. The compiler is case sensitive.
After successfully compiling the source code with no errors, a Hello.class file is created in the same directory. That file contains the intermediate code necessary to run the program.