Introduction to Java Applet5 min read

Java Applet

Java Applet is a GUI application that is part of an HTML document and is delivered over the internet using World Wide Web (WWW) browsers.

  • An applet is not a typical, self-contained main program under the control of the user, The WWW browser allocates a rectangular region of the document to the applet. The applet is invoked by a WWW browser and is under its control.
  • An applet is controlled by the browser; there is no main program. java.applet and java.awt library is used to build an applet.
  • An HTML (HyperText Markup Language) file with the appropriate information about the applet’s class must be provided to run an applet.
  • An Applet class is an Abstract Windowing Toolkit (AWS) component.
  • The applet provides the following functionalities,
    • GUI components and containers can be embedded in an applet to build a GUI.
    • Rendering operations can be performed onto an applet by overriding the paint() method.


  • Applets are programs built in the Java programming language.
  • In 1994, “WebRunner” – afterward known as “The HotJava Browser” – was released as the first browser that could display applets.
  • To put applets on your pages, you don’t need to know Java. For nearly any function, there are thousands of free applets available on the internet. The majority of them can be changed without the need for programming.
  • Some people, however, have disabled the ability to run applets in their browsers. In most cases, this is a company that is concerned about potential hacking.
  • Whatever their motivation, it’s a truth that a small percentage of people will not be able to see your applets, even if their browser is capable of doing so. This should be considered when selecting whether or not to include applets on your website.
  • A web page can have an applet embedded in it. Typically, the applet offers a number of settings that allow you to customize it. You can specify which options should be in the menu and which sites should be loaded when a user clicks on an option, for example, if you introduce an applet that will act as a menu.
  • There aren’t many constraints to Java because it’s a genuine programming language. Any programs you have installed on your computer could have been created as an applet. Java may be used to create spreadsheets, word processors, graphical programs, and even complete browsers.

Applet life cycle methods

An Applet class defines the following methods.

Java applet life cycle
Java applet life cycle
  • init() – called first and called only once
  • start() – called every time applet is displayed on the screen
  • paint() – called when display is damaged
  • update() – called when applet requests to redraw a portion of its window
  • stop() – called when browser no longer is displaying applet.
  • destroy() – called when the browser decides that applet is no longer needed.
import java.awt. * ;
import java.applet. * ;
public class AppSturcture extends Applet{
  public void init() {
  public void start(){
  public void stop() {
  public void destroy(){
  public void paint (Graphics g) {


Any or all of the following features can be found in a Java applet:

  • It’s easy to make it work on Linux, Windows, and Mac OS, which means the same applet can run on “all” installed versions of Java at the same time, rather than simply the most recent plug-in version. If an applet requires a newer version of the JRE, the client will be forced to wait while the huge download is completed.
  • It is supported by most web browser applets, allowing users to develop in their preferred J2SE environment.
  • It will get better with use: after the first applet is played, the JVM is already running and begins quickly, which will help regular Java users, but the JVM will have to restart each time the browser starts up.
  • It can run at a pace similar to (though generally slower than) other compiled languages like C++, but several times quicker than JavaScript.
  • It has the ability to transfer work from the server to the client, making a web solution more scalable as the number of users/clients grows.
  • Creating the main routine (either in the applet’s class or in a different class) and calling init() and start() on it allows developers to design and debug an applet directly.
  • After that, just re-test the Java applet in the appletviewer application or in a web browser to confirm that it complies with security constraints.


A Java applet can suffer from any of the following drawbacks:

  • It necessitates the use of the Java plug-in, which is not included by default in all web browsers.
  • An implementation of the Sun Java plug-in does not exist for AMD64/Inte164 processors. 1
  • It cannot start until the Java Virtual Machine is running, and this may have a significant startup time the first time it is used.
  • If the user is untrustworthy, it has severely restricted access to the user’s system, including no direct access to the client’s disc or clipboard (although some would argue that this is a security benefit rather than a disadvantage, as unrestricted access to a client’s disc would be extremely dangerous).
  • Some organizations only enable administrators to install the software. As a result, a large number of users are unable to display applets by default. A special JRE.2 may be required for applets.


Leave a Reply