Java
Java
Introduction to
Applets
Applets are special Java programs that are embedded within web pages and
executed by a Java-enabled web browser. They provide interactive and dynamic
content, enhancing the user experience on the web.
Definition of Applets
Applets enable the creation of Applets can run on any platform Applets are designed with a
interactive and dynamic web that has a Java Virtual Machine robust security model, ensuring
content, enhancing user (JVM), providing cross-platform the safety of the host system and
engagement. compatibility. the user's data.
Applet Life Cycle
1 Init()
This method is called when the applet is first loaded, and it is used to initialize the
applet's resources.
2 Start()
The Start() method is called when the applet becomes active and should begin
executing its code.
3 Stop()
The Stop() method is called when the applet should pause its execution, such as
when the user navigates away from the web page.
Applet Security Model
Sandbox Restricted Access
Applets run in a secure "sandbox" environment, Applets have restricted access to the local file
which limits their access to local system resources system, network, and other sensitive areas of the
to ensure the safety of the host system. host system to prevent unauthorized access or
malicious activities.
Code Attribute
The "code" attribute specifies the location of the applet's class file, which contains
the Java code.
Archive Attribute
The "archive" attribute can be used to specify a JAR file containing the applet's
resources, such as images and other assets.
Applet Communication with JavaScript