Online coverage from the Sun Developer Network staff 2008 JavaOne Conference

Tuesday May 06, 2008

Applets Reloaded:
Introducing the Next-Generation
Java Plug-In Technology

by Dana Nourie, Sun Microsystems, Staff Writer

If you were frustrated with applets in the past, or completely given up on them, it's time to take another look at the new Java Plug-In technology. Now you can reap the following advantages from the rewritten support:

  • Improved reliability
  • Improved user experience
  • Applets launch in the background
  • Built-in JNLP support
  • Per-applet command line arguments
  • Heap size, Java 2D™ API acceleration options...
  • Improved Java/JavaScript programming language integration
  • Improved Windows Vista support
  • Signed applets now work correctly in Protected Mode Internet Explorer

The next-generation Java Plug-In, new in Java SE 6 Update 10, 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.

Applets no longer execute in a Java Virtual Machine (JVM) inside the web browser. Instead, a separate JVM machine process is launched to execute the applets. Applets launch directly from JNLP files, make use of the
same descriptor used by Java Web Start software, and allow more powerful parameters than classic “archive”, “code”, “cache_archive.”

The new plug-in provides:

  • access to advanced JNLP extensions previously available only to Java Web Start software applications. A small set was previously available, with restrictions, and these restrictions have now been removed.
  • access to the JNLP APIs from applets
  • PersistenceService, DownloadService
  • control over heap size, command-line arguments, JRE version selection, and auto-download. You have the same capabilities as Java Web Start software for applications

Now, you use something like the following on the web page:

<applet width=”500” height=”500”>
  <param name=”jnlp_href” value=”my_applet.jnlp”>
</applet>

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.

The applet behaves exactly like an application started with Java Web Start software. jnlp_href parameter bridges between the web page and the JNLP description of the applet. Applet tag and JNLP file have overlapping mechanisms for specifying things like the width and height.

Historically, the maximum heap size that could be specified for applets via the Java Control Panel has been limited. This limitation is fixed in the new Java Plug-In; 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:

    <param name=”separate_jvm” value=”true” />

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:

<j2se version=”1.4+” ...>
<j2se version=”1.5*” ...>

This is useful for enterprises that want to QA an applet against a particular JRE version, or it supersedes earlier version selection mechanisms like CLSID in Internet Explorer. If a very old JRE version is requested, restrictions are enforced the user will be prompted if applet attempts to load unsigned code.

Note that since JNLP support is first available in Java Plug-In in Java Platform, Standard Edition 6 (Java SE 6) Update 10, version specifications like “1.4+” are basically meaningless. This will have more meaning when “1.7+” is needed.

In addition, you can use the <update> tag in the JNLP file to drastically reduce startup time for second and subsequent launches:

       <update check=”background”> 

In this case, it'll use the version of the applet that is already in the cache, and will download updated versions of the applet in the background. At the next launch the new version is picked up.

Lastly, it's much easier to maintain backwards compatibility, to create your own corporate logo or animated image for loading time, as well as controlling background colors and overall appearance, there is powerful Java/JavaScript integration, and support for access to Web Services.

Applets are mini applications that run anywhere, in and out of the browser.

For more information, see the Release Notes Next-Generation Plug-In


 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed