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 Demo.java that prints Hello World on applet window.
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.
<applet code="Demo.class" width="200" height="225">
Output Screenshot of First.html of Java Applet
More Examples, Styles of executing Java Applet in detail and Explanation is available at: