How to create a Java applet
Make sure that both files are located in the same directory (folder)!
- Write source code and save it as .java file.
A sample code (Hello.java) might look like:
public class Hello extends Applet
public void paint(Graphics g)
- Compile the source code.
If you compile Hello.java, you will get Hello.class
(You can do it from
the command line prompt javac filename.java or using bluej )
- Create a simple HTML file that contains <APPLET> tag.
A sample HTML might look like:
<APPLET code="Hello.class" width=400 height=400>
Note: You may use
any text editor to create html files. You may also give any name to the html
file, as long as the extension is .html or .htm
- Open the html file in one of the following two ways: