What are the differences between an application and an applet in Java?

JavaObject Oriented ProgrammingProgramming

A Java program can be classified into two types, one is an Application and another is an Applet.

Application

  • An application is a stand-alone java program that runs with the support of a virtual machine in a client or server-side.
  • A java application is designed to perform a specific function to run on any Java-compatible virtual machine regardless of the computer architecture.
  • An application is either executed for the user or for some other application program.
  • Examples of java applications include database programs, development tools, word processors, text and image editing programs, spreadsheets, web browsers, etc.

Example

public class Demo {
   public static void main(String args[]) {
      System.out.println(“Welcome to TutorialsPoint”);
   }
}

Output

Welcome to TutorialsPoint

Applet

  • An applet is specifically designed to be executed within an HTML web document using an external API.
  • They are basically small programs, more like the web version of an application that requires a Java plugin to run on the client browser.
  • Applets run on the client-side and are generally used for internet computing.
  • When we see an HTML page with an applet in a Java-enabled web browser, the applet code gets transferred to the system and is finally run by the Java-enabled virtual machine on the browser.

Example

import java.awt.*;
import java.applet.*;
public class AppletDemo extends Applet{
   public void paint(Graphics g) {
      g.drawString("Welcome to TutorialsPoint", 50, 50);
   }
}
/* <applet code="AppletDemo.class" width="300" height="300">
   <applet>*/
raja
Published on 31-May-2019 18:08:56
Advertisements