Java web start jnlp file

Creating the Web Page That Launches the Application

The following information predates the introduction of the Deployment Toolkit script in the Java SE 6 update 10 release.
See Deployment in the Browser for information about using the Deployment Toolkit script.

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.MySite.com , the page needs to include the following link:

It may be the case, however, that Java Web Start 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 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 JDK/JRE.

    The scripts, and the HTML for the auto-install page, are discussed below.

    Detecting if Java Web Start is installed on Netscape

    Here is the first script that should be run on a web page for launching an application via JNLP:

     var javawsInstalled = 0; var javaws142Installed=0; var javaws150Installed=0; var javaws160Installed = 0; isIE = "false"; if (navigator.mimeTypes && navigator.mimeTypes.length) < x = navigator.mimeTypes['application/x-java-jnlp-file']; if (x) < javawsInstalled = 1; javaws142Installed=1; javaws150Installed=1; javaws160Installed = 1; >> else

    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 be Netscape and the JNLP MIME type is checked to see if it exists on Netscape. If so, javawsInstalled , javaws142Installed , javaws150Installed and javaws160Installed are all set to 1. With Netscape it is not possible to determine which particular version of Java Web Start is installed, so all four 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:

      

    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. This script instantiates the isInstalled COM object in JavaWebStart.dll, and this object determines four things:

    • whether the client machine has any version of Java Web Start installed;
    • whether the client machine has version 1.2 of Java Web Start installed;
    • whether the client machine has versions 1.4.2 of Java Web Start installed;
    • whether the client machine has versions 1.5.0 of Java Web Start installed.
    • whether the client machine has versions 1.6.0 of Java Web Start installed.

    After the above two scripts have been executed, the variables javawsInstalled, javaws142Installed , javawsInstalled150 and javawsInstalled160 will be set to either 1 or 0, as follows:

    Источник

    Running a Java Web Start Application

    Note: To run applications deployed with Java Web Start technology, you must have a compatible version of the Java Runtime Environment (JRE) software. The complete Java Java Development Kit (JDK) is not required.

    Running a Java Web Start Application From a Browser

    You can run a Java Web Start application from a browser by clicking a link to the application’s JNLP file. The following text is an example of a link to a JNLP file.

    Java Web Start software loads and runs the application based on instructions in the JNLP file.

    Running a Java Web Start Application From the Java Cache Viewer

    If you are using at least Java Platform, Standard Edition 6 or later, you can run a Java Web Start application through the Java Cache Viewer.

    When Java Web Start software first loads an application, information from the application’s JNLP file is stored in the local Java Cache Viewer. To launch the application again, you do not need to return to the web page where you first launched it; you can launch it from the Java Cache Viewer.

    To open the Java Cache Viewer:

    1. Open the Control Panel.
    2. Double click on the Java icon. The Java Control Panel opens.
    3. Select the General tab.
    4. Click View. The Java Cache Viewer opens.

    The application is listed on the Java Cache Viewer screen.

    A screen shot of the Java Cache Viewer application

    Java Cache Viewer application

    To run the application, select it and click the Run button, , or double click the application. The application starts just as it did from the web page.

    Running a Java Web Start Application From the Desktop

    You can add a desktop shortcut to a Java Web Start application. Select the application in the Java Cache Viewer. Right-click and select Install Shortcuts or click the Install button, .

    A shortcut is added to the desktop.

    You can then launch the Java Web Start application just as you would launch any native application.

    Источник

    Читайте также:  Least squares fit in python
Оцените статью