Applet Deployment Techniques for Platform Deterministic Libraries

From time to time WebRenderer is deployed within an Applet. Applets provide a convenient mechanism for launching client applications within the browser. WebRenderer however requires different libraries based on the target platform (Windows, Linux, OS X, Solaris) and architecture (32/64 bit). Traditionally to run an Applet, you needed to specify all of the libraries that are required, and they will all be downloaded. If you intend for the Applet to run on multiple platforms, then traditional Applet deployment means that all the libraries for the supported platforms are required which results in the downloading of many unnecessary files.

All is not lost however. It is possible to launch an Applet in a way that will only download the relevant files for the target system. This is done through a JNLP file that is usually associated and used with Java Web Start programs. The JNLP deployment option for Applets was introduced in Java 1.6.0_10.

Details on using JNLP with Applets can be found here.

The following code is an example JNLP file that can be utilized to deploy an Applet with platform targeted libraries.

  1. <!--?xml version="1.0" encoding="UTF-8"?-->
  2. <jnlp spec="1.0+" codebase="" href="webrenderer-applet.jnlp">
  3. <security>
  4. <all-permissions>
  5. </all-permissions></security>
  6. <!-- Resources for all platforms -->
  7. <resources>
  8. <j2se version="1.6+">
  9. <jar href="TestBrowser.jar">
  10. <jar href="webrenderer-swing.jar">
  11. </jar></jar></j2se></resources>
  12. <!-- Platform specific resources -->
  13. <resources os="Windows" arch="amd64">
  14. <jar href="webrenderer-swing-windows64.jar">
  15. <jar href="corecomponents-swing-windows64.jar">
  16. </jar></jar></resources>
  17. <resources os="Windows" arch="x86">
  18. <jar href="webrenderer-swing-windows32.jar">
  19. <jar href="corecomponents-swing-windows32.jar">
  20. </jar></jar></resources>
  21. <resources os="Linux" arch="amd64">
  22. <jar href="webrenderer-swing-linux64.jar">
  23. <jar href="corecomponents-swing-linux64.jar">
  24. </jar></jar></resources>
  25. <resources os="Linux" arch="i386 x86">
  26. <jar href="webrenderer-swing-linux32.jar">
  27. <jar href="corecomponents-swing-linux32.jar">
  28. </jar></jar></resources>
  29. <resources os="Mac\ OS\ X" arch="x86_64">
  30. <jar href="webrenderer-swing-osx64.jar">
  31. <jar href="corecomponents-swing-osx64.jar">
  32. </jar></jar></resources>
  33. <resources os="Mac\ OS\ X" arch="i386 x86">
  34. <jar href="webrenderer-swing-osx32.jar">
  35. <jar href="corecomponents-swing-osx32.jar">
  36. </jar></jar></resources>
  37. <resources os="Sun" arch="sparc">
  38. <jar href="webrenderer-swing-solaris32.jar">
  39. <jar href="corecomponents-swing-solaris32.jar">
  40. </jar></jar></resources>
  41. <applet-desc name="TestBrowser Applet" main-class="TestBrowserApplet.class" width="900" height="700">
  42. </applet-desc>
  43. </jnlp>

This JNLP file (webrenderer-applet.jnlp) specifies the WebRenderer libraries as resources under different Operating Systems and Architectures. Through this deployment specification only the files needed are downloaded to the target machine. For demonstration purposes WebRenderer is run from a simple program called TestBrowser (included with the WebRenderer download) and is specified at the end of the JNLP file above under “applet-desc”.

Enabling JNLP deployment for Applets requires an extra param tag to be added inside the Applet tag that refers to the JNLP file:

  1. <code>
  2. <param name="jnlp_href" value="webrenderer-applet.jnlp">
  3. </code>

The architecture used on a particular platform by the Applet depends on the Java architecture that the browser is using. So on a 64-bit OS that is using 32-bit Java, the 32-bit WebRenderer libraries will be used.

The values for “arch” property are the same as is returned in Java by the function:

  1. System.getProperty("os.arch")

As with all Applets, each library will need to be signed. Details on signing your Applets resources can be found here..

And for more information on WebRenderer, please visit us here.

© 2008 SYS-CON Media