![]() |
|||||||||||||
|
Java applet |
| This article does not cite any references or sources. Please help improve this article by adding citations to reliable sources. Unverifiable material may be challenged and removed. (March 2008) |
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 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.
Contents |
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 [1], or the recommended object element [2]. This specifies the applet's source and the applet's location statistics.
A Java applet extends the class java.applet.Applet, or in the case of a Swing applet, 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 Panel which is a descendant of Container).
A Java applet can have any or all of the following advantages:
A Java applet is open to any of the following disadvantages:
1. However, open source and freeware implementations are available, such as the GCJ plugin, and Blackdown Java plugin. This is fixed as of 6u10.
2. Applet may specify java version as of 6u10.
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).citation needed 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.citation needed 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.citation needed
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.citation needed
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.
|
|||||||||||||||||||||||||||||||