How do I create a Hello World Applet?

The code below demonstrate the very basic of Java applet. Applet is a small Java application that can be embedded on the web browser.

package org.kodejava.applet;

import java.applet.*;
import java.awt.*;

public class HelloWorldApplet extends Applet {
    public void init() {

    public void start() {

    public void stop() {

    public void destroy() {

    public void paint(Graphics g) {
        g.drawString("Hello World", 50, 100);

To display the applet we need to create an HTML document. Here is a simple example of the document.

<!DOCTYPE html>
<html lang="en">
    <title>Hello World Applet</title>


You can now load the applet in your browser or by using the appletviewer utility.

appletviewer.exe hello-world-applet.html

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.