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.example.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.

    <title>Hello World Applet</title>


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


Programmer, runner, recreational diver, live in the island of Bali, Indonesia. Mostly programming in Java, Spring Framework, Hibernate / JPA. Support me, buy me ☕ or 🍵

Leave a Reply