Applets are back! It's time to take another look at Java applet technology for delivering your programs over the web. The Next-Generation Java Plug-in Technology runs applets in a different, more efficient and more reliable way than ever before. Now you can reap the following benefits:
The next-generation Java Plug-in offers a completely redesigned architecture, and is available in the Java SE 6 Update 10. This plug-in provides powerful new capabilities to applets in the web browser, while improving the overall reliability and functionality of applets in a backward-compatible manner. The most significant new feature of the next-generation Java Plug-in is built-in support for launching applets from JNLP files. Using the JNLP file format as the applet descriptor allows applets to instantly reuse JNLP extensions previously written for Java Web Start applications, and significantly expands the capabilities of applets in many other ways. The new way of executing applets has architectural similarities to Java Web Start technology, but tighter browser integration. Applets no longer execute in a Java Virtual Machine (JVM) inside the web browser. Instead, a separate JVM machine process is launched to execute applets. By default, only one JVM machine is launched, but you have the opportunity to launch more than one JVM machine, and you get support per-applet command-line arguments, so you can affect heap size or other requests.
In Figure 1 above, the clouds represent JVM instances. There is a small, headless JVM inside the browser that is used to manage the connections to one or more client JVMs that actually run the applets. In the diagram the Dukes represent applets. One JVM instance is running two applets and the other is running one. Applets launch directly from JNLP files, make use of the same descriptor used by Java Web Start software, and allow more powerful parameters than the classic “archive", “code", and “cache_archive" parameters. The new plug-in provides:
Now, you use something like the following on the web page:
Calls to the applet lifecycle methods The applet behaves exactly like an application started with Java Web Start software. In general you should use the Deployment Toolkit, also new in Java SE 6 Update 10, to automatically generate the HTML for the applet tag. The deployment advice guide shows how to easily and portably deploy applets using the Deployment Toolkit. Now, it's also much easier to configure applets in several areas, including heap size, the Java version that needs to be used, classloader cache, borders, and more. The
In the past, the maximum heap size that could be specified for applets through the Java Control Panel was limited. This limitation is fixed in the new Java Plug-in, and applets can now utilize as much heap space as command-line applications.
An applet may force itself into its own JVM machine instance separate from all other applets if you like:
This is useful when migrating certain kinds of desktop applications to work in the web browser. You can also run a particular applet on a particular version of the JRE, as shown below:
This approach is useful for enterprises that want to QA an applet against a particular JRE version, or the applet supersedes earlier version selection mechanisms like CLSID in Internet Explorer. If a very old JRE version is requested, restrictions are enforced and the user will be prompted if the applet attempts to load unsigned code. Note that since JNLP support is first available in Java Plug-in in the Java Platform, Standard Edition 6 (Java SE 6) Update 10, version specifications like In addition, you can use the <update> tag in the JNLP file to drastically reduce startup time for second and subsequent launches:
In this case, it will use the version of the applet that is already in the cache, and downloads updated versions of the applet in the background. At the next launch, the new version is picked up. The new plug-in also offers better customization of the image, which is displayed before the applet is loaded. Animated GIFs are now supported as the target of the image parameter, as described in the Special Attributes section of the Java Plug-in Developers' Guide. Additionally, the following new parameters are now supported: boxborder A boolean parameter indicating whether a one-pixel border should be drawn around the edge of the applet's area while displaying the image shown before the applet is loaded. Defaults to true. We recommend setting this value to centerimage A boolean parameter indicating whether the loading image should be centered within the area of the applet instead of originating at the upper left corner. Defaults to Example using the boxborder and centerimage parameters:
It's now much easier to maintain backwards compatibility. You can author content that runs with earlier versions of Java Plug-in, but which takes advantage of new features by simply providing a fully-formed The NASA World Wind Java applet example, by the World Wind Java development team, illustrates how to deploy leading-edge libraries like NASA World Wind Java, as well as how to effectively combine HTML and content in a web page using JavaScript.
The web page contains information about the Cascade mountain range (thanks to Wikipedia) and embeds World Wind Java as an applet to illustrate the locations of the mountains in the range. Incorporating World Wind in a web page is remarkably easy. Here is the
The Here are the relevant portions of the
Some items to note:
The HTML links on the web page call JavaScript functions which interact with the applet to navigate it to the appropriate mountain. Here is an example of one of these links:
When the link is clicked, the JavaScript function gotoLocation is called. It is defined on the same web page:
The locations of the mountains are encoded as JavaScript strings in the HTML of the web page. The latitude, longitude, and other viewing information is parsed out of these strings and passed into the applet. The
As mentioned above, the preferred method of incorporating World Wind Java into your application or applet is as a JNLP extension. This allows the World Wind code resources to be shared among many applications or applets from around the web which incorporate it. To reference the World Wind JNLP extension, you would add the following lines to your application's or applet's JNLP file in the <resources> section:
Note that the World Wind extension JNLP is versioned, so you would need to consult the World Wind documentation or visit the forums to find the most current version to reference from your JNLP. The World Wind Central site is a useful source of up-to-date information on World Wind. Using World Wind as an extension implies that you can not use the
Compile this with The introduction of JNLP support in the Java Plug-in opens up many new possibilities for applet deployment and represents a large step forward in the unification of the deployment of Java content both in and out of the browser. Applets have come a long way since their inception, and now with the JNLP support, they're faster and more customizable than ever.
Release Notes for the Next-Generation Java Plug-in Technology | ||||||||||||||||||||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||