You are on page 1of 2

A Java applet is a small application written in Java and delivered to users in the form of

bytecode. The user launches the Java applet from a web page and it is then executed
within a Java Virtual Machine (JVM) in a process separate from the web browser itself. A
Java applet can appear in a frame of the web page a new application window !un"s
AppletViewer or a stand#alone tool for testing applets. Java applets were introduced in
the first version of the Java language in $%%&.
Java applets can be written in any programming language that compiles to Java
bytecode. They are usually written in Java but other languages such as Jython'()
J*uby'%) +ascal'$,) !cala or -iffel (via !mart-iffel)'$$) may be used as well.
Java applets run at very fast speeds comparable to but generally slower than other
compiled languages such as .//. 0ntil approximately 1,$$ Java applets had been
many times faster than Java!cript.'$1) 0nli2e Java!cript Java applets have access to
34 hardware acceleration ma2ing them well suited for non#trivial computation intensive
visuali5ations. As browsers have gained support for hardware accelerated graphics
than2s to the canvas technology (or specifically 6eb78 in the case of 34 graphics) as
well as 9ust in time compiled Java!cript the speed difference has become less
!ince Java"s bytecode is cross#platform (or platform independent) Java applets can be
executed by browsers (or other clients) for many platforms including Microsoft 6indows
:ree;!4 0nix <! = and 8inux. >t is also trivial to run a Java applet as an application
with very little extra code so that it can be run directly from the integrated development
environment (>4-).Applets are used to provide interactive features to web applications
that cannot be provided by ?TM8 alone. They can capture mouse input and also have
controls li2e buttons or chec2 boxes. >n response to the user action an applet can
change the provided graphic content. This ma2es applets well suitable for
demonstration visuali5ation and teaching. There are online applet collections for
studying various sub9ects from physics'$3) to heart physiology.'3)
An applet can also be a text area only providing for instance a cross platform
command#line interface to some remote system.'$@) >f needed an applet can leave the
dedicated area and run as a separate window. ?owever applets have very little control
over web page content outside the applet dedicated area so they are less useful for
improving the site appearance in general (while applets li2e news tic2ers'$&) or
6A!>6A7 editors'$B) are also 2nown). Applets can also play media in formats that are
not natively supported by the browser'$C)
?TM8 pages may embed parameters that are passed to the applet. ?ence the same
applet may appear differently depending on the parameters that were passed.
As applets were available before .!! and 4?TM8 were standard they were also widely
used for trivial effects li2e rollover navigation buttons. ?eavily critici5ed this usage is
now declining.'$()
Technical information'edit)
Java applets are executed in a sandbox by most or all web browsers preventing them
from accessing local data li2e the clipboard or file system. The code of the applet is
downloaded from a web server and the browser either embeds the applet into a web
page or opens a new window showing the applet"s user interface.
A Java applet extends the class 9ava.applet.Applet or in the case of a !wing applet
9avax.swing.JApplet. The class must override methods from the applet class to set up a
user interface inside itself (Applet) is a descendant of +anel which is a descendant of
.ontainer. As applet inherits from container it has largely the same user interface
possibilities as an ordinary Java application including regions with user specific
The first implementations involved downloading an applet class by class. 6hile classes
are small files there are freDuently a lot of them so applets got a reputation as slow
loading components. ?owever since 9ars were introduced an applet is usually delivered
as a single file that has a si5e similar to a large image file (hundreds of 2ilobytes to
several megabytes).
The domain from where the applet executable has been downloaded is the only domain
to which the usual (unsigned) applet is allowed to communicate. This domain can be
different from the domain where the surrounding ?TM8 document is hosted.
Java system libraries and runtimes are bac2wards compatible allowing one to write
code that runs both on current and on future versions of the Java virtual machine.