HelloWorld

Setting Up the Web Server

Applications can be deployed from any standard web server. Java Web Start leverages existing internet technology, such as the HTTP protocol and web servers, so existing infrastructure for deploying HTML-based content can be reused to deploy Java Technology-based applications using Java Web Start.

To deploy your application to client machines, ensure that all files that contain your application are accessible through a web server. This typically requires copying one or more JAR files and a JNLP file into the web server’s directories. Enabling the website to support Java Web Start is similar to deploying HTML-based content. In addition, to use Java Web Start, the web server must be configured to support the application/x-java-jnlp-file MIME type.

Step 1: Configure the web server to use the Java Web Start MIME type.

Many web servers come with the Java Web Start MIME type configured by default. If your web server does not, configure it 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 the 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 add the following line to the .mime.types configuration file:

Check the documentation for the specifics of your web server.

Step 2: Create a JNLP file for the application.

The easiest way to create this file is to modify an existing JNLP file with your requirements. A simple JNLP file is shown in the following example:

    HelloWorld demo application      

The syntax and format for the JNLP file is described in JNLP File Syntax.

Step 3: Make the application accessible on the web server.

Ensure that your application’s JAR files and the JNLP file are accessible at the URLs listed in the JNLP file.

Step 4: Create the web page that launches the application.

Create the web page and include one of the following options for starting a Java Web Start application:

Читайте также:  Java jpeg to base64

    Use a link to the JNLP file, as shown in the following examples:

Launch HelloWorld demo Launch DynamicTree demo Launch DynamicTree demo 
  

Installing the Java Web Start Protocol Handler

Java Web Start includes a protocol handler to handle the custom URI schemes jnlp: and jnlps: . Use these schemes as a direct way to start Java Web Start applications.

The protocol handler is automatically installed on Windows and macOS systems. It must be manually installed on Linux systems.

Installing the Protocol Handler for Chrome

If you use the Chrome browser on Linux, manually install the protocol handler that enables you to start Java Web Start applications using the jnlp or jnlps protocol.

In Linux, the xdg-open command is used to open a file or URL in the user’s preferred application. To install the protocol handler, configure xdg-open to use Java Web Start for URLs that include the jnlp or jnlps protocol:

  1. Use a text editor to create a file named javaws.desktop in the ~/.local/share/applications directory.
  2. Include the statements shown in the following example.
[Desktop Entry] Encoding=UTF-8 Name=Java(TM) Web Launcher Exec=jre-home/bin/javaws %U Terminal=false Type=Application MimeType=x-scheme-handler/jnlp;x-scheme-handler/jnlps
xdg-mime default javaws.desktop x-scheme-handler/jnlp xdg-mime default javaws.desktop x-scheme-handler/jnlps

After installing the protocol handler, Java Web Start is used to launch applications when the URL contains the jnlp or jnlps protocol. For example, the following URL starts the Dynamic Tree sample from the Java Tutorials:

jnlps://docs.oracle.com/javase/tutorialJWS/samples/deployment/dynamictree_webstartJWSProject/dynamictree_webstart.jnlp

Installing the Protocol Handler in Firefox

If you use the Firefox browser on Linux, manually install the protocol handler that enables you to start Java Web Start applications using the jnlp or jnlps protocol.

To install the protocol handler, add properties to the Firefox configuration:

  1. In the address bar in Firefox, enter about:config . If you see a page with a warning about voiding your warranty, click I’ll be careful, I promise! to continue to the configuration page.
  2. Add a Boolean property.
    1. Right-click on the page and select New, and then select Boolean.
    2. In the New Boolean Value window, enter the name network.protocol-handler.expose.jnlp and click OK.
    3. Select false for the value and click OK.

    The property is added to the configuration.

    When you enter a URL or click a link that uses the jnlp or jnlps protocol, you are prompted to choose the application to use to open the file. Select Java Web Start Launcher or browse to the javaws.exe file in jre-home/bin .

    Источник

    Java Web Start Overview

    Java Web Start software provides a flexible and robust deployment solution for Java technology-based applications based on the Java Community Process program (JCP). The technology is being developed through the JCP program as JSR-56: The Java Network Launching Protocol & API (JNLP), which provides a browser-independent architecture for deploying Java 2 technology-based applications to the client desktop.

    Java Web Start technology works with any browser and any Web server. Each application developed for use with the Java Web Start software specifies which version of the Java 2 platform it requires, e.g., version 1.4 or 1.5, and each application runs on a dedicated Java Virtual Machine (JVM).

    Auto-download of Software from Java

    A main feature of the Java Network Launching Protocol and API technology is the ability to automatically download and install Java Runtime Environments onto the users machine.

    For example, an application might depend APIs in Sun’s Java Runtime Environment 1.4.0 (or later). When a user first accesses this application, the Java Web Start software will download all the needed files for the application, as well as download the Java Runtime Environment (JRE) if the requested version is not available locally. The ability to automatically download a JRE is one of the key features to ensure robust deployments. It ensures that the JRE that your application is tested on will be available on the user’s machine, as well as make it possible to seamlessly upgrade to improved versions of the Java 2 platform over time.

    The auto-download feature simplifies Java Web Start deployments because it makes commonly used software readily available for use with Java Web Start. Typically, only an extra line has to be added to a JNLP file to take advantage of this feature. In contrast, without the auto-download feature, developers would be forced to repackage and host the software themselves — adding a significant overhead to the deployment burden. As an added benefit to both developers and end-users, this minimizes the download time for an application since each JRE will be shared between multiple applications.

    The packages currently available for auto-download are:

    • Java 2 Runtime Environment 1.3.0_02 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.3.1_08 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.3.1_09 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.3.1_11 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.3.1_18 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.0 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.1_02 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.1_07 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_01 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_04 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_12 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_13 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_09 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_14 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java 2 Runtime Environment 1.4.2_16 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_02 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_06 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_07 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_08 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_09 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_10 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_11 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.5.0_14 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.6.0 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.6.0_04 for Windows/i586, Linux/i586, and Solaris/SPARC
    • Java Runtime Environment 1.6.0_05 for Windows/i586, Linux/i586, and Solaris/SPARC

    Because the Java Web Start Java Runtime Environment installer uses Verisign certificates, the autodownload from here works only if the client machine has version 1.3 or later of the Java Runtime Environment installed.

    How to Request a Specific Version of the Java Runtime Environment

    The «j2se . » element is used to specify the set of Java Runtime Environments that your application supports. They can be specified both as a vendor-independent platform-version and as a vendor-dependent product version.

    Specifying a platform version: Currently, there are three different platforms supported: 1.2, 1.3, 1.4, and 1.5. For example:
    j2se version=»1.4 1.3+»
    j2se version=»1.4″

    The order in which the platforms are specified matters. In the above example, the application prefers the 1.4 platform, but can run on a 1.3 platform and above. Java Web Start will automatically do a request to the auto-download site and download a JRE matching this request if none are found locally.

    Specifying a product version: A product version is specified by including a vendor-specific URL from where to download the JRE.

    Example 1

    j2se version=»1.4.2*» href=»http://goo.gl/oWqMb»

    In the above example, a product version that has 1.4.2 as a prefix is requested, e.g., 1.4.2, 1.4.2_02, 1.4.2_04 would match.

    Example 2

    j2se version=»1.4.0_01+» href=»http://goo.gl/oWqMb»

    In the above example, a product version that is equal to or greater than 1.4.0_01 is requested.

    To request a particular version, you should specify a particular dot-dot release (e.g., 1.4.2* as shown above). Specifying a dot-dot-dot release (e.g., 1.4.2_02) is possible but not recommended — since it might force your customers to use an unsupported JRE. Specifying a dot-dot release assures that your customers always will download the latest supported release.

    Источник

Оцените статью