All Topics  
Java applet

 

   Email Print
   Bookmark   Link






 

Java applet



 
 
A Java applet is an applet
Applet

An applet is a software component that runs in the context of another program, for example a web browser. An applet usually performs a very narrow function that has no independent use....
 delivered to the users in the form of Java bytecode
Java bytecode

Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode instruction or opcode is one byte in length; however, not all of the possible 256 instructions are used....
. Java applets can run in a Web browser
Web browser

A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
 using a Java Virtual Machine
Java Virtual Machine

A Java Virtual Machine is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and Scripting language....
 (JVM), or in Sun
Sun Microsystems

Sun Microsystems, Inc. is a multinational corporation vendor of computers, computer components, computer software, and information technology services, founded on February 24, 1982....
's AppletViewer
AppletViewer

AppletViewer is a standalone, command line program from Sun Microsystems to run Java applets. Appletviewer is generally used by developers for testing their applets before being deployed to a website....
, a stand-alone tool for testing applets. Java applets were introduced in the first version of the Java language in 1995. Java applets are usually written in the Java programming language
Java (programming language)

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java ....
 but they can also be written in other languages that compile to Java bytecode such as Jython
Jython

Jython, successor of JPython, is an implementation of the Python written in Java ....
.

Applets are used to provide interactive features to web applications that cannot be provided by HTML
HTML

HTML, an Acronym and initialism of HyperText Markup Language, is the predominant markup language for Web pages. It provides a means to describe the structure of text-based information in a document?by denoting certain text as links, headings, paragraphs, lists, and so on?and to supplement that text with interactive forms, embedded '...
.






Discussion
Ask a question about 'Java applet'
Start a new discussion about 'Java applet'
Answer questions from other users
Full Discussion Forum



Encyclopedia


A Java applet is an applet
Applet

An applet is a software component that runs in the context of another program, for example a web browser. An applet usually performs a very narrow function that has no independent use....
 delivered to the users in the form of Java bytecode
Java bytecode

Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode instruction or opcode is one byte in length; however, not all of the possible 256 instructions are used....
. Java applets can run in a Web browser
Web browser

A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
 using a Java Virtual Machine
Java Virtual Machine

A Java Virtual Machine is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and Scripting language....
 (JVM), or in Sun
Sun Microsystems

Sun Microsystems, Inc. is a multinational corporation vendor of computers, computer components, computer software, and information technology services, founded on February 24, 1982....
's AppletViewer
AppletViewer

AppletViewer is a standalone, command line program from Sun Microsystems to run Java applets. Appletviewer is generally used by developers for testing their applets before being deployed to a website....
, a stand-alone tool for testing applets. Java applets were introduced in the first version of the Java language in 1995. Java applets are usually written in the Java programming language
Java (programming language)

Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java ....
 but they can also be written in other languages that compile to Java bytecode such as Jython
Jython

Jython, successor of JPython, is an implementation of the Python written in Java ....
.

Applets are used to provide interactive features to web applications that cannot be provided by HTML
HTML

HTML, an Acronym and initialism of HyperText Markup Language, is the predominant markup language for Web pages. It provides a means to describe the structure of text-based information in a document?by denoting certain text as links, headings, paragraphs, lists, and so on?and to supplement that text with interactive forms, embedded '...
. Since Java's bytecode
Bytecode

Bytecode is a term which has been used to denote various forms of instruction sets designed for efficient execution by a software Interpreter as well as being suitable for further compilation into machine language....
 is platform independent, Java applets can be executed by browsers for many platforms, including Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
, Unix
Unix

Unix is a computer operating system originally developed in 1969 by a group of American Telephone & Telegraph employees at Bell Labs, including Ken Thompson , Dennis Ritchie, Douglas McIlroy, and Joe Ossanna....
, Mac OS
Mac OS

Mac OS is the trademarked name for a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems....
 and Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
. There are open source tools like which can be used to convert an applet to a stand alone Java application/windows executable/linux executable. This has the advantage of running a Java applet in offline mode without the need for internet browser software.

Many influential Java developers, blogs and magazines are recommending that the Java Web Start
Java Web Start

In computing, Java Web Start , a Software framework developed by Sun Microsystems, allows users to start application software for the Java Platform directly from the Internet using a web browser....
 technology be used in place of Applets .

A Java Servlet
Java Servlet

Servlets are Java programming language objects that dynamically process requests and construct responses. The Java Servlet API allows a software developer to add dynamic content to a Web server using the Java platform....
 is sometimes informally compared to be "like" a server-side applet, but it is different in its language, functions, and in each of the characteristics described here about applets.

Technical information

Java applets are executed in a sandbox by most web browsers, preventing them from accessing local data. The code of the applet is downloaded from a web server
Web server

The term web server can mean one of two things:# A computer program that is responsible for accepting Hypertext Transfer Protocol requests from clients , and Server them HTTP responses along with optional data contents, which usually are web pages such as Hypertext Markup Language documents and linked objects ....
 and the browser either embeds the applet into a web page or opens a new window showing the applet's user interface
User interface

The user interface is the aggregate of means by which people—the User s—Interaction with the system—a particular machine, device, computer program or other complex tools....
. The applet can be displayed on the web page by making use of the deprecated applet HTML element
HTML element

In computing, an HTML element indicates structure in an HTML document and a way of hierarchically arranging content. More specifically, an HTML element is an Standard Generalized Markup Language element that meets the requirements of one or more of the HTML Document Type Definitions ....
 , or the recommended object element . This specifies the applet's source and the applet's location statistics.

A Java applet extends the class , or in the case of a Swing
Swing (Java)

Swing is a widget toolkit for Java . It is part of Sun Microsystems' Java Foundation Classes — an Application programming interface for providing a graphical user interface for Java programs....
 applet, . The class must override methods from the applet class to set up a user interface inside itself (Applet is a descendant of which is a descendant of ).

Advantages

A Java applet can have any or all of the following advantages:
  • it is simple to make it work on Linux, Windows and Mac OS i.e. to make it cross platform
  • the same applet can work on "all" installed versions of Java at the same time, rather than just the latest plug-in
    Plug-in

    For the term plug-in, see* Plug-in , an auxiliary computer program* Plug-in hybrid electric vehicle* Plugging in , a mathematical procedure in which substitutions are made in a formula...
     version only. However, if an applet requires a later version of the JRE the client will be forced to wait during the large download.
  • it is supported by most web browser
    Web browser

    A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
    s
  • it will cache
    Cache

    In computer science, a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch or to compute, compared to the cost of reading the cache....
     in most web browsers, so will be quick to load when returning to a web page but may get stuck in the cache and have issues when new versions come out.
  • it can have full access to the machine it is running on if the user agrees
  • it can improve with use: after a first applet is run, the JVM is already running and starts quickly, benefitting regular users of Java but the JVM will need to restart each time the browser starts fresh.
  • it can run at a speed that is comparable to (but generally slower than) other compiled languages such as C++
    C++

    C++ is a general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level programming language and low-level programming language language features....
    , but many times faster than JavaScript
    JavaScript

    JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard....
  • it can move the work from the server
    Server (computing)

    A server is a computer program that provides services to other computer programs , in the same or other computer. The physical computer that runs a server program is also often referred to as server....
     to the client
    Client (computing)

    A client is an Application software or system that accesses a remote service on another computer system, known as a Server , by way of a Computer network....
    , making a web solution more scalable with the number of users/clients
  • developers can develop and debug an applet direct simply by creating a main routine (either in the applet's class or in a separate class) and call init and start on the applet, thus allowing for development in their favorite J2SE development environment. All one has to do after that is re-test the applet in the appletviewer program or a web browser to ensure it conforms to security restrictions.


Disadvantages

A Java applet is open to any of the following disadvantages:
  • It requires the Java plug-in
    Plug-in

    For the term plug-in, see* Plug-in , an auxiliary computer program* Plug-in hybrid electric vehicle* Plugging in , a mathematical procedure in which substitutions are made in a formula...
    , which isn't available by default on all web browser
    Web browser

    A Web browser is a application software which enables a user to display and interact with text, images, videos, music, games and other information typically located on a Web page at a website on the World Wide Web or a local area network....
    s.
  • Prior to version 6u12, Sun did not provide a 64-bit
    64-bit

    64-bit CPUs have existed in supercomputers since the 1960s and in RISC-based computer workstation and Server s since the early 1990s. In 2003 they were introduced to the mainstream personal computer arena, in the form of the x86-64 and 64-bit PowerPC processor architectures....
     version of its Java plug-in
    Plug-in

    For the term plug-in, see* Plug-in , an auxiliary computer program* Plug-in hybrid electric vehicle* Plugging in , a mathematical procedure in which substitutions are made in a formula...
    , forcing users to use the 32-bit plugin with a 32-bit browser.1
  • It cannot start until the Java Virtual Machine
    Java Virtual Machine

    A Java Virtual Machine is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and Scripting language....
     is running, and this may have significant startup time the first time it is used.
  • If untrusted, it has severely limited access to the user's system - in particular having no direct access to the client's disk or clipboard (although some would argue that this is a security benefit instead of a disadvantage, as ad-hoc unrestricted access to a client's disk would be incredibly dangerous).
  • Some organizations only allow software installed by the administrators. As a result, many users cannot view applets by default.
  • Applets may require a specific JRE.2


1. However, open source
Open source

Open source is an approach to design, development, and distribution offering practical accessibility to a product's source . Some consider open source as one of various possible design approaches, while others consider it a critical Strategy element of their business operations....
 and freeware
Freeware

Freeware is computer software that is available for use at no cost or for an optional fee. Freeware is different from shareware; the latter obliges the user to pay ....
 implementations are available, such as the GCJ plugin, and Blackdown Java
Blackdown Java

Blackdown Java is a port of Sun Microsystems's Java virtual machine to Linux by a group of volunteers led by Karl Asha. It predates Sun's official Linux port....
 plugin.


2. Applet may specify java version as of 6u10.

Compatibility issues

Sun
Sun Microsystems

Sun Microsystems, Inc. is a multinational corporation vendor of computers, computer components, computer software, and information technology services, founded on February 24, 1982....
 has made a considerable effort to ensure compatibility is maintained between Java versions as they evolve. For example, Microsoft
Microsoft

Microsoft Corporation is a multinational corporation computer technology corporation that develops, manufactures, licenses, and supports a wide range of computer software products for computing devices....
's Internet Explorer
Internet Explorer

Windows Internet Explorer , commonly abbreviated to IE, is a series of graphical user interface web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems starting in 1995....
, the most popular web browser since the late 1990s, used to ship with the Microsoft Java Virtual Machine
Microsoft Java Virtual Machine

The Microsoft Java Virtual Machine is a proprietary Java Virtual Machine computer program from Microsoft. It was first made available for Internet Explorer Internet Explorer 3 so that users could run Java applets when browsing on the World Wide Web....
 as the default. The MSJVM had some extra non-Java features added which, if used, would prevent MSJVM applets from running on Sun's Java (but not the other way round). Sun sued for breach of trademark
TradeMark

TradeMark is a tall, primarily residential, skyscraper in Charlotte, North Carolina. It was completed in 2007 and has 28 floors. There are 200 hundred residential units....
, as the point of Java was that there should be no proprietary extensions and that code should work everywhere. Development of MSJVM was frozen by a legal settlement, leaving many users with an extremely outdated Java virtual machine. Later, in October 2001, MS stopped including Java with Windows, and for some years it has been left to the computer manufacturers to ship Java independently of the OS.

Some browsers (notably Netscape) do not do a good job of handling height=100% on applets which makes it difficult to make an applet fill most of the browser window (JavaScript
JavaScript

JavaScript is a scripting language widely used for client-side web development. It was the originating Programming language dialect of the ECMAScript standard....
 can, with difficulty, be used for this). Having the applet create its own main window is not a good solution either, as this leaves the browser window as a largely useless extra window and leads to a large chance of the applet being terminated unintentionally by the user closing the parent browser window.

Alternatives

Alternative technologies exist (for example, DHTML, Flash
Adobe Flash

Adobe Flash is a multimedia Platform created by Macromedia and currently developed and distributed by Adobe Systems. Since its introduction in 1996, Flash has become a popular method for adding animation and interactivity to web pages; Flash is commonly used to create animation, advertisements, and various web page components, to integrate...
, and Microsoft Silverlight
Microsoft Silverlight

Microsoft Silverlight is a programmable web browser plugin that enables features such as animation, vector graphics and multimedia that characterizes rich Internet applications....
) that satisfy some of the scope of what is possible with an applet.

Another alternative to applets for client side Java is Java Web Start
Java Web Start

In computing, Java Web Start , a Software framework developed by Sun Microsystems, allows users to start application software for the Java Platform directly from the Internet using a web browser....
, which runs outside the browser. In addition to the features available to applets, a simple permissions box can give Java Web Start programs read and/or write access to specified files stored on the client, and to the client's clipboard.

See also


  • JavaFX
    JavaFX

    JavaFX is a software platform for creating and delivering rich Internet applications that can run across wide variety of connected devices. The current release enables building applications for desktop, browser and mobile phones....
  • Java Servlet
    Java Servlet

    Servlets are Java programming language objects that dynamically process requests and construct responses. The Java Servlet API allows a software developer to add dynamic content to a Web server using the Java platform....
  • Java Web Start
    Java Web Start

    In computing, Java Web Start , a Software framework developed by Sun Microsystems, allows users to start application software for the Java Platform directly from the Internet using a web browser....
  • ActiveX control
    ActiveX

    ActiveX is a component Object Model developed by Microsoft for Microsoft Windows. By using the Component Object Model runtime, developers can create Component-based software engineering that perform a particular function or a set of functions....
  • Java programming language
    Java (programming language)

    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java ....


External links

  • (includes browser plug-ins for running Java applets in most web browsers).
  • Applet section of Wikibook's Java book
  • (JDK 1.4 - include source code)