Java Web Start 1.4.2 Developer Guide

Java Web Start 1.4.2 Developer Guide

Java Web Start 1.4.2 Developer Guide Overview Java Web Start Technology Where to Find Java Web Start Technology Desktop and Server Requirements Setting up the Web Site Introduction Basic Steps Creating the Web Page That Launches the Application Introduction Detecting if Java Web Start is installed on Netscape Detecting if Java Web Start is installed on IE, and if so, the version number Launching the application if Java Web Start is Installedor providing a link for auto-install or general download page Creating an auto-install page Application Development Considerations Introduction Retrieving Resources from JAR files Security and Code Signing Signing JAR Files with a Test Certificate How to Encode JNLP Files Dynamic Download of HTTPS Certificates Packaging an Application for Easy Deployment JNLP File Syntax Introduction The jnlp Element The security Element The resources Element The application-desc Element The applet-desc Element JNLP API Examples Introduction Using a BasicService Service Using a ClipboardService Service Using a DownloadService Service Using a FileOpenService Service Using a FileSaveService Service Using a PrintService Service Using a PersistenceService Service Using FileContents Using a JNLPRandomAccessFile Appendices: Converting JNLP Files to Work With This Release FAQ (Not available in PDF) JNLP API (JavaDoc) (Not available in PDF) Overview Java Web Start Technology Java Web Start is a helper application that gets associated with a Web browser. When a user clicks on a link that points to a special launch file (JNLP file), it causes the browser to launch Java Web Start, which then automatically downloads, caches, and runs the given Java Technology-based application. The entire process is typically completed without requiring any user interaction, except for the initial single click. JNLP URLs are also directly openable from the JAWS Application Manager and can be bookmarked. Moreover, they may be .html or .jnlp files. From a technology standpoint, Java Web Start has a number of key benefits that make it an attractive platform to use for deploying applications: ● Java Web Start is built exclusively to launch applications written to the Java 2 SE platform. Thus, a single application can be made available on a Web server and then deployed on a wide variety of platforms, including Windows 98/NT/2000/ME/XP, Linux, and the SolarisTM Operating Environment. The Java platform has proven to be a very robust, productive, and expressive development platform, leading to a significant cost savings due to minimized development and testing costs. ● Java Web Start supports multiple revisions of the Java 2 platform, Standard Edition. Thus, an application can request a particular version of the platform it requires, such as J2SETM 1.4.0. Several applications can run at the same time on different platform revisions without causing conflicts, and Java Web Start can automatically download and install a revision of the platform if an application requests a version that is not installed on the client system. ● Java Web Start allows applications to be launched independently of a Web browser. This can be used for off-line operation of an application, where launching through the browser is often inconvenient or impossible. The application can also be launched through desktop shortcuts, making launching the Web-deployed application similar to launching a native application. ● Java Web Start takes advantage of the inherent security of the Java Platform. Applications are by default run in a protective environment (sandbox) with restricted access to local disk and network resources. It allows the user to safely run applications from sources that are not trusted. ● Applications launched with Java Web Start are cached locally. Thus, an already-downloaded application is launched on par with a traditionally installed application. The technology underlying Java Web Start is the Java TM Network Launching Protocol & API (JNLP). This technology is currently under development via the Java Community Process (JCP). Java Web Start is the reference implementation (RI) for the JNLP specification. The JNLP technology defines, among other things, a standard file format that describes how to launch an application called a JNLP file. Where to find Java Web Start See the Java Web Start web site, http://java.sun.com/products/javawebstart/, for availability of Java Web Start downloads. The JNLP specification can be found at http://java.sun.com/aboutJava/communityprocess/jsr/jsr_056_jnlp.html. Requirements Desktop/Client requirements: The client machine requires support for the Java Runtime Environment (JRE), version 1.2.2 or later. Java Web Start is available for Windows 98/NT/2000/ME/XP, the Solaris Operating Environment, and Linux. See the README document for details. Server requirements: Applications can be deployed from any standard Web server. In order to use Java Web Start, the Web server must be configured with support for a new MIME type as explained below. Setting Up the Web Site Introduction Java Web Start leverages existing Internet technology, such as the HTTP protocol and Web servers, so existing infrastructure for deploying HTML-based contents can be reused to deploy Java Technology-based applications using Java Web Start. In order to deploy your application to client machines, you must make sure that all files containing your application are accessible through a Web server. This typically amounts to copying one or more JAR files, along with a JNLP file, into the Web server's directories. The set-up required for enabling the Web site to support Java Web Start is very similar to deploying HTML-based contents. The only caveat is that a new MIME type needs to be configured for the Web server. Basic Steps 1. Configure the Web server to use the Java Web Start MIME type Configure the Web server so that all files with the .jnlp file extension are set to the application/x-java-jnlp-file MIME type. Most Web browsers use the MIME type returned with the contents from the Web server to determine how to handle the particular content. The server must return application/x-java-jnlp-file MIME type for JNLP files in order for Java Web Start to be invoked. Each Web server has a specific way in which to add MIME types. For example, for the Apache Web server you must add the following line to the .mime.types configuration file: application/x-java-jnlp-file JNLP Check the documentation for the specifics of your Web server. 2. Create a JNLP file for the application The easiest way to create this file is to modify an existing JNLP file to your requirements. The syntax and format for the JNLP file is described in a later section. 3. Make the application accessible on the Web server Ensure your application's JAR files and the JNLP file are accessible at the URLs listed in the JNLP file. 4. Create the web page that launches the application See the next chapter, Creating the Web Page that launches the Application, for details on step 4. Creating the Web Page That Launches the Application This chapter includes the following topics: ● Introduction ● Detecting if Java Web Start is installed on Netscape ● Detecting if Java Web Start is installed on IE, and if so, the version number ● Launching the application if Java Web Start is Installedor providing a link for auto-install or general download page ● Creating an auto-install page Introduction In order for an application to be launched from a web page via JNLP, the page must include a link to the JNLP file. E.g., to be able to launch application app.jnlp on a web site http://www.yyy.zzz, the page needs to include the following link: <a href=http://www.yyy.zzz/app.jnlp>Launch the application</a> It may be the case, however, that JAWS is not installed on the user's computer. Thus the page needs to include logic (scripts) to take account of this. In fact, the page should include logic for the following: Detect if Java Web Start (JAWS) is installed ● If so, launch the application. ● If not, detect if user is running IE on Window. ❍ If so, provide link to a page that can auto-install the JRE for Windows ❍ If not, provide a link to the general download page for the SDK/JRE. The scripts, and the HTML for the auto-install page, are discussed below. Detecting if JAWS is installed on Netscape Here is the first script that should be run on a web page for launching an application via JNLP: <SCRIPT LANGUAGE="JavaScript"> var javawsInstalled = 0; var javaws12Installed = 0; var javaws142Installed=0; isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) { x = navigator.mimeTypes['application/x-java-jnlp-file']; if (x) { javawsInstalled = 1; javaws12Installed=1; javaws142Installed=1; } } else { isIE = "true"; } </SCRIPT> This script looks at the navigator.mimeTypes object and the navigator.mimeTypes.length var to decide if the browser is Netscape or IE. If length is 0, it is assumed the browser is IE, as with IE the navigator.mimeTypes array is defined but always empty. If length is non-zero, then the browser is assumed to by Netscape and the JNLP MIME type is checked to see if it exists on Netscape. If so, javawsInstalled, javaws12Installed, and javaws142Installed are all set to 1. With Netscape it is not possible to determine which particular version of JAWS is installed, so all three variables are set to 1. Detecting if JavaWeb Start is installed on IE, and if so, the version The above JavaScript should be followed by a VBScript that sets variables related to Internet Explorer browers: <SCRIPT LANGUAGE="VBScript"> on error resume next If isIE = "true" Then If Not(IsObject(CreateObject("JavaWebStart.isInstalled"))) Then javawsInstalled = 0 Else javawsInstalled = 1 End If If Not(IsObject(CreateObject("JavaWebStart.isInstalled.2"))) Then javaws12Installed = 0 Else javaws12Installed = 1 End If If Not(IsObject(CreateObject("JavaWebStart.isInstalled.3"))) Then javaws142Installed = 0 Else javaws142Installed = 1 End If End If </SCRIPT> This VBScript is executed if the variable isIE from the preceeding JavaScript is "true"; i.e., if the end-user's browser is Internet Explorer.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    33 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us