Introduction to Applet

What is an Applet?

According to Sun:-

“An applet is a small program that is intended not to be run on its own, but rather to be embedded inside another application.

  • An applet is a Java program that runs on a web page.
  • An applet is compiled on one computer and can run on another computer through a Java-enabled Web browser.
  • Applet viewer is a program that can run an applet.

Web Browsers Accessing a Web Page:

 Web Browsers Accessing a Web Page

Web Server Sending Response To Web Browser:

Web Server Sending Response To Web Browser

Web Server Sending Response To Web Browser:

Web Server Sending Response To Web Browser (2)

Advantages of an Applet:

  • It is simple to make it work across platform.
  • It runs in a sandbox, so the user does not need to trust the code, so it can work without security approval.
  • It is supported by most web browsers.
  • It will cache in most web browsers, so will quick to load when returning to a web page.
  • The applet can work on all installed versions of Java rather than just the latest plugin version only.
  • It can improve with use: after a first applet is run, the JVM is already running and starts quickly, benefiting regular users of Java.

Disadvantages of an Applet:

  • It requires the default plug-in, which isn’t available by default on all web browsers.
  • It can’t start up until the JVM is running, and this may have significant startup time the first time it is used.
  • It is considered to difficult to build and design a good user interface with than with HTML-based technologies.
Life Cycle of an Applet:
  • init – To initialize the applet each time it’s loaded (or reloaded).
  • start -To start the applet’s execution, such as when the applet’s loaded or when the user revisits a page that contains the applet.
  • stop -To stop the applet’s execution, such as when the user leaves the applet’s page or quits the browser.
  • destroy -To perform a final cleanup in preparation for unloading.

Not every applet needs to override every one of these methods.


Security Issues in Context of Applet:

  • Every browser implements security policies to keep applets from compromising system security.
  • Current browsers impose the following restrictions on any applet that is loaded over the network:
    An applet cannot load libraries or define native methods.
    It cannot ordinarily read or write files on the host that’s executing it.
    It cannot make network connections except to the host that it came from.
    It cannot start any program on the host that’s executing it.
    It cannot read certain system properties.
    Windows that an applet brings up look different than windows that an application brings up.


Leave a Reply

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