答案:Developer's Guide
Java TM Web Start
Version 1.0
This developer's guide provides documentation on how to deploy applications using Java TM Web Start and the JNLP technology.
Please send comments and feedback to javawebstart-feedback@eng.sun.com.
Table of Contents
Java Web Start Technology
Where to find Java Web Start
Requirements (desktop and server)
Setting up the Web site
Application Development Considerations
Converting JNLP files to work with this release
JNLP File Syntax
JNLP API Examples
JNLP API (JavaDoc)
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.
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 95/98/NT/2000, Linux, and Solaris. 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 Java 2 SE 1.3.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, 易做图 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.
Java Web Start is browser independent and mostly platform independent. Thus, it works with virtually all browsers, and is expected to be ported to all platforms that supports Java 2 SE in a relatively short time frame.
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
Java Web Start can be downloaded from http://java.sun.com/products/javawebstart/. 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 Version 1.0 is available for Windows 95/98/NT/2000, Solaris (SPARC & Intel editions), and Linux (RH6.1/x86).
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
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.
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 uses 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 a link from the Web page to the JNLP file
The link to the JNLP file is a standard HTML link. For example:
<a href=>
Given the setup in step 1, the Web server will automatically return the application/x-java-jnlp-file MIME type with any file with the .jnlp extension. This is critical for 易做图 sure that a Web browser will launch Java Web Start when downloading the file.
A link to the Java Web Start installer should also be provided on the Web page, so users who do not already have Java Web Start installed can download and install the software.
Detecting if Java Web Start is installed
It is possible to detect if Java Web Start is installed by using a little bit of javascript/VBScript in the HTML page. Using this sample script below, a link to an application can be inserted as:
<SCRIPT LANGUAGE="javascript">
<!--
insertLink("http://www.mycompany.com/my-app.jnlp",
"My Application");
// -->
</SCRIPT>
The insertLink method detects if Java Web Start is installed or not. If it is installed, the HTML will be similar to:
<a href="http://www.mycompany.com/m
上一个:Java Web Start 1.0 Architecture
下一个:Java Web Start 1.0 developers guide (2)