Pular para o conteúdo

Conheça Walt Disney World

Java applet

Java applet that was created as a supplementary demonstration material of the scientific publication.[1] and is available from the university site
Java applet that uses 3D hardware acceleration, downloading from the server 3D files in .pdb format to visualize[2]
Using Java applet for computation - intensive visualization of the Mandelbrot set[3]
Sufficient running speed is also utilized in applets for playing non trivial computer games like chess [[4]]
NASA World Wind (open source) is a second generation applet [5] that heavily uses OpenGL and on-demand data downloading to provide detailed 3D map of the world.

A Java applet is an applet delivered to the users 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 or Eiffel[6].

Applets are used to provide interactive features to web applications that cannot be provided by HTML alone. They can capture mouse input (like rotating 3D object) and also have controls like buttons or check boxes. In response to the user action an applet can change the provided graphic content. This makes applets well suitable for demonstration, visualization and teaching purposes. For instance, a complete suite for ordinary differential equations course has been written[7]. An applet can also be text area only, providing, for instance, cross platform command-line interface to some remote system[8]. If needed, applet can leave the dedicated area and run as separate window. However applets have very little, if any control on web page content that is outside the applet dedicated area, so they are less useful for improving the site appearance in general.

Java applets run at a speed that is comparable to (but generally slower than) other compiled languages such as C++, but many times faster than JavaScript[9]. In addition they can use 3D hardware acceleration that is available from Java. This makes applets well suitable for non trivial, computation intensive visualizations.

HTML page may embed parameters that are passed to the applet. Hence the same applet may appear differently depending on that parameters were passed. First implementations were downloading an applet class by class. While classes are small files, there are frequently a lot of them, so applets got a reputation of slow loading components. However since jars were introduced an applet is usually delivered as a single file that has a size of the bigger image (hundreds of kilobytes to several megabytes).

Since Java's bytecode is platform independent, Java applets can be executed by browsers for many platforms, including Windows, Unix, Mac OS and Linux. It is also trivial to run Java applet as an application with very little extra code. This has the advantage of running a Java applet in offline mode without the need for internet browser software and also directly from the development IDE.

Many Java developers, blogs and magazines are recommending that the Java Web Start technology be used in place of Applets [10][11].

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

Technical information

Java applets are executed in a sandbox by most web browsers, preventing them from accessing local data like 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. The applet can be displayed on the web page by making use of the deprecated applet HTML element [2], or the recommended object element [3]. 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. As applet inherits from container, it has largely the same user interface possibilities as an ordinary Java application, including regions with user specific visualization.

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. Applets are supported by most web browsers
  • 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.
  • Most web browsers cache applets, so will be quick to load when returning to a web page. Applets also improve with use: after a first applet is run, the JVM is already running and starts quickly (JVM will need to restart each time the browser starts fresh).
  • It can move the work from the server to the client, making a web solution more scalable with the number of users/clients
  • If standalone program (like Google Earth) talks to the web server, that server normally needs to support also previous versions as the user may not keep it always updated. Differently, the browser updates the applet so there is no need to support the legacy versions. Only due configuration mistakes the applet may get stuck in the cache and have issues when new versions come out.
  • The applet naturally supports the changing user state like figure positions on the chessboard.
  • 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.
  • An untrusted applet has no access to the local machine and can only access the server it came from. This makes such applet much safer to run than standalone executable that it could replace. However signed applet can have full access to the machine it is running on if the user agrees.

Disadvantages

A Java applet may have any of the following disadvantages:

  • It requires the Java plug-in that may not available on some less popular web browser or operating systems.
  • Some organizations only allow software installed by the administrators. As a result, some users can only view applets that are important enough to contact the administrator asking to install Java plug-in.
  • As with any client side scripting, security restrictions may make difficult or even impossible for untrusted applet to achieve the desired goals.
  • Some more badly designed code may require a specific JRE [12].

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[citation needed], 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]

Applet security

There are two applet types with very different security model: signed applets and unsigned applets.

Unsigned applet

Limitations for the unsigned applets are understood as "draconian" [13]: they have no access to the local filesystem, web access limited to the applet download site, there are also many other important restrictions. For instance, they cannot access system properties, use they own class loader, call native code, execute external commands on a local system or redefine classes belonging to the certain packages. While they can run in standalone frame, such frame contains a header, indicating that this is an untrusted applet. Several specific security problems have been discovered and fixed since Java was first released. However as of 1998 no real security breaches involving Java have ever been publicly reported, while this reference is now dated [4]. Using an up-to-date Web browser is usually enough to be safe safe against the known attacks from unsigned applets.

Signed applet

Signed applet [5] contains a signature that the browser should verify through remotely running, independent certificate authority server. Producing this signature and attaching it to the applet is part of the applet development process that involves specialized tools. Once the signature is verified and then the user of the current machine also approves, signed applet can get more rights, becoming equivalent to the ordinary standalone program. The rationale is that the author of the applet is now known and will be responsible for any deliberate damage. This approach allows to use applets for many tasks that are otherwise not possible by client side scripting. However this approach require more responsibility from the user, deciding whom he/she is trusting.

Java security problems are not fundamentally different from similar problems of any client side scripting platform.

Alternatives

Alternative technologies exist (for example, JavaScript, 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

References

  1. ^ World of Fungi - page of the scientific project, serving an applet that is used as an illustration figure
  2. ^ The home site of the 3D protein viewer (Openastexviewer) under LGPL
  3. ^ The home site of the Mandelbrot set applet under GPL
  4. ^ The home site of the chess applet under BSD
  5. ^ http://java.sun.com/developer/technicalArticles/javase/newapplets/
  6. ^ SmartEiffel can compile into Java bytecode
  7. ^ The d'Arbeloff Interactive Math Project
  8. ^ http://www.jcraft.com/jcterm/
  9. ^ An example of the 2005 year performance benchmarking
  10. ^ http://www.javaworld.com/javaworld/jw-07-2001/jw-0706-webstart.html
  11. ^ http://javachannel.net/wiki/pmwiki.php/FAQ/Applets
  12. ^ Applet may specify java version as of 6u10
  13. ^ [1]

External links