Java applet

Java applet

A Java applet is an applet delivered in the form of Java bytecode. Java applets can run in a Web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, 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 but they can also be written in other languages that compile to Java bytecode such as Jython.

Applets are used to provide interactive features to web applications that cannot be provided by HTML. Since Java's bytecode is platform independent, Java applets can be executed by browsers for many platforms, including Windows, Unix, Mac OS and Linux.There are open source tools like [http://sourceforge.net/projects/applet2app applet2app] 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.

A Java Servlet 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 and the browser either embeds the applet into a web page or opens a new window showing the applet's user interface. The applet can be displayed on the web page by making use of the deprecated applet HTML element [http://www.w3.org/TR/html401/struct/objects.html#edef-APPLET] , or the recommended object element [http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT] . This specifies the applet's source and the applet's location statistics.

A Java applet extends the class Javadoc:SE|package=java.applet|java/applet|Applet, or in the case of a Swing applet, Javadoc:SE|package=javax.swing|javax/swing|JApplet. The class must override methods from the applet class to set up a user interface inside itself (Applet is a descendant of Javadoc:SE|java/awt|Panel which is a descendant of Javadoc:SE|java/awt|Container).

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 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 browsers
*it will 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++, but many times faster than JavaScript
*it can move the work from the server to the client, making a web solution more scalable with the number of users/clients

Disadvantages

A Java applet is open to any of the following disadvantages:
*it requires the Java plug-in, which isn't available by default on all web browsers.
*an implementation of the Sun Java plug-in does not exist for AMD64/Intel64 processors.1
*it cannot start until the Java Virtual Machine 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.
*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.
*because of the platform independent nature of Java, it may be undesirably slow.

1. However, open source and freeware implementations are available, such as the GCJ plugin, and Blackdown Java plugin. There is request for enhancement to [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4802695 Support Java Plug-in on 64-bit AMD and Intel] .

Compatibility issues

Sun has made a considerable effort to ensure compatibility is maintained between Java versions as they evolve. For example, Microsoft's Internet Explorer, the most popular web browser since the late 1990s, used to ship with the Microsoft Java Virtual Machine 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).Fact|date=February 2008 Sun sued for breach of trademark, 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 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, and Microsoft Silverlight) 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, 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
* Java Servlet
* Java Web Start
* ActiveX control
* Java programming language

External links

* [http://www.java.com/download/ Latest version of Sun Microsystems Java Virtual Machine] (includes browser plug-ins for running Java applets in most web browsers).
* [http://java.sun.com/docs/books/tutorial/applet/index.html Information about writing applets from Sun Microsystems]
*
* [http://java.sun.com/applets/jdk/1.4/index.html Demonstration applets from Sun Microsystems] (JDK 1.4 - include source code)
* [http://conceptualeclipse.googlepages.com/pressuresimulation Interactive Java Pressure Simulation Applet]
* [http://cmol.nbi.dk/models Examples of interactive Java Applets from physics, biology and social systems]
* [http://javaboutique.internet.com/javasource/ examples for Java Applets with sourcecode]
* [http://www.home.hs-karlsruhe.de/~frhe0012/Snake.html another example with sourcecode]
* [http://www.lalaclick.net applet for visual interaction with last.fm data]
* [http://faq.javaranch.com/java/AppletsFaq JavaRanch Applet FAQ]

Java (Sun)ooo


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • Java-Applet —   [sprich dschawa äpplet; dt. »kleine Java Anwendung«], ein kleines, nicht allein lauffähiges Programm, das in der Internet tauglichen Programmiersprache Java geschrieben wurde. Java Applets ermöglichen es, HTML Seiten interaktiv zu gestalten,… …   Universal-Lexikon

  • Java Applet — Ein Java Applet ist ein Computerprogramm, das in der Programmiersprache Java verfasst wurde und normalerweise in einem Webbrowser ausgeführt wird. Sie wurden eingeführt, um Programme in Webseiten ablaufen lassen zu können, die im Webbrowser (auf… …   Deutsch Wikipedia

  • Java-Applet — Ein Java Applet ist ein Computerprogramm, das in der Programmiersprache Java verfasst wurde und normalerweise in einem Webbrowser ausgeführt wird. Sie wurden eingeführt, um Programme in Webseiten ablaufen lassen zu können, die im Webbrowser (auf… …   Deutsch Wikipedia

  • Java applet —    A small program written in the Java programming language designed to add a specific capability to a Web page. The applet is stored on the Web server and is downloaded to and executes within the browser.    Java applets are inserted into a Web… …   Dictionary of networking

  • Java-Applet — In Java für das Internet entwickelte Anwendung, läuft auf den meisten gängigen Browsern. Applet, Browser, Internet, Java, Java Virtual Machine …   Online-Wörterbuch Deutsch-Lexikon

  • Java applet — small application program that performs a specific task and is included in some web sites (Internet) …   English contemporary dictionary

  • Applet Java — Applet Desarrollador Sun Microsystems http://java.sun.com/applets Información general Género ? …   Wikipedia Español

  • Applet java — Une Applet java est une applet, fournie aux utilisateurs sous la forme de bytecode Java. Une applet Java peut fonctionner dans un navigateur internet, grâce à une machine virtuelle Java (JVM), ou dans l AppletViewer de Sun, un outil permettant de …   Wikipédia en Français

  • Java Card — (JC) refers to a technology that allows small Java based applications (applets) to be run securely on smart cards and similar small memory footprint devices. Java Card is the tiniest of Java targeted for embedded devices. Java Card gives the user …   Wikipedia

  • Java (informatique) — Java (langage) Pour les articles homonymes, voir Java.  Ne doit pas être confondu avec JavaScript …   Wikipédia en Français

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”