Java Applet

Java is known as Internet-based language (one of the features of Java) due to Java Applets and Servlets. Applets lie on the client-side to communicate with Servlets on server-side.
Java comes with two types of programs – Applications and Applets.

The basic difference is that applications contain manin() method and applets do not. Moreover, Java Applet comes with special methods like init(), start() and paint() etc.

Following example on Java Applet that prints Hello World on applet window.
import java.applet.Applet;
import java.awt.Graphics;
public class Demo extends Applet
  public void paint(Graphics g)
    g.drawString("Hello World", 50, 100);
    g.drawString("Best Wishes from way2java Readers", 50, 125);
To run the above Demo applet, write one more file First.html.

Write source codes and execute the applet as in following screen.
Java Applet

Output Screenshot of First.html of Java Applet

Java Applet

More Examples, Styles of executing Java Applet in detail and Explanation is available at:

1. Applets Vs Applications
2. Life Cycle of Applet
3. Drawing Strings & Graphics – Simple Applet Program

Leave a Comment

Your email address will not be published.