Java Applets

Applet is an interactive image embeded in a HTML page with IMG tag. It reacts to user commands, changes its appearance, and sends data between the computer viewing the applet and the computer serving it

A Java applet is a small application which is written in Java and it is delivered to users in the form of byte code. We need a JVM to view an applet.  We can launch the Java applet from a web page . Applet is then executed within a Java Virtual Machine (JVM) .

We can describe the characteristics of an applet as follows:

  1. An applet is a Java program that runs in a Web browser.  
  2. Applet is a kind of window application
  3. Applets are similar to Flash
  4. They are designed to be embedded within an HTML page.
  5. When we view an HTML page which contains an applet, at that time the code for the applet is downloaded to the our machine.Pages coded in HTML may embed parameters within them that are passed to the applet. Because of this, the same applet may have a different appearance depending on the parameters that were passed.
  6.  Applet is a Java class that extends the java.applet.Applet class or javax.swing.JApplet.
  7. An applet class does not define main().
  8. Applets have strict security rules enforced by the Web browser. The security of an applet is referred to as sandbox security, which is like comparing the applet to a child who is playing in a sandbox with various rules to follow.
  9. We can’t get applets using firebug.
  10. An applet is  delivered as a single .jar file , size similar to an image file (hundreds of kilobytes to several megabytes).

Uses of Applets:
  1. Applets are used to provide interactive features to web applications that cannot be provided by HTML alone. Applets can capture mouse input and also have controls like buttons or check boxes. In response to user actions, an applet can change the provided graphic content. This makes applets well-suited for demonstration, visualization, and teaching. We can find various applet collections online for the purpose of studying various subjects, from physics to heart physiology.The code of the applet is downloaded from a web server, after which the browser either embeds the applet into a web page or opens a new window showing the applet's user interface. 
  2. An applet can also be a text area only; which provides, a cross-platform command-line interface to some remote system. 
  3. Based on the requirement , an applet can run as a separate window .
  4. Applets can also play media in formats that are not supported by the browser. 
  5. Applets were also largely used for trivial effects such as rollover navigation buttons however, this usage is now declining.
  6. Applets can not access local data like the clipboard or file system because they are executed in a sandbox by most web browsers.