5.12.2.3 Introduction to Java Web Start Interface

 

In this topic we will discuss about the following topics

 



 

Java Web Start in Java Client - A Foreword

 

Java Web Start is the latest client side technology introduced by Sun Microsystems. This new "application-deployment technology" gives the power to launch full-featured java applications from the omnipresent Web browser. The technology bundles with it, rich features which includes: Advanced caching, Multiple JRE support, Sandboxing, Desktop Integration and others.

 

Web NMS has been long supporting Java Client in two flavours namely, Applet and Application mode. Acknowledging the value addition provided by the Web Start technology, Web NMS Java Client now also supports the Java Web Start interface (Note from now on JWS Interface will be acronym that will be used across this document to refer to "Java Web Start Interface"). You can now access the Web NMS Java Client in any of the three deployment types (Application, Applet and Web Start).

 

The Web Start Interface is built over the Web NMS Java Application Client base. Hence the behavior of the Web Start interface would be similar to that of the Application Client. We will learn more about this in the subsequent topics presented in this document.

 

A Quick Introduction to Java Web Start

 

We will cover some basics about Java Web Start in this sub-section. The goal is just to provide you a quick overview about this technology and its benefits. You can find comprehensive information about this technology in the official product site by Sun Microsystems.

 

What is Java Web Start?

 

Traditionally distributing any Application, necessitates the installation of the respective application in the user computer (system). This procedure also had the overhead of keeping the installed application version abreast with the globally available latest version. Java Web Start is the plumbing between the computer and the Internet that allows the user to launch and manage applications right off the Web. It provides easy, one-click activation of applications, and guarantees that you are always running the latest version, eliminating complicated installation or upgrade procedures.

 

Upon launching a Java Web Start based application for the first time, the user may download the new client application from the Web; thereafter these applications may be initiated either through a link on a Web page (this is the way in which JWS interface is provided for Web NMS Java Client) or from desktop icons or the Start menu. Applications initialize quickly under Java Web Start, are cached on the client machine, and can be launched remotely offline.

    1. Note: JWS Interfaced Web NMS Java Client, can be launched from the web page similar to the Applet Client (in the same page). Additionally it should be noted that the client cannot be launched remotely offline since it requires an active connection to the Web NMS Server.

Why use Java Web Start?

 

Java Web Start gives the end users the cross-breed of both Application and Applet client technologies. Some of the highlighting features of the Java Web Start are:

 

Intelligent and Advanced Caching

 

Provides a mechanism to download the class binaries of the application only on the first start of the application. Subsequently on restarts, it only downloads the modified contents. This alleviates the needed manual intervention of upgrading the applications to the latest versions. Applications also initialize quickly under Java Web Start, as they are cached on the client machine.

 

Multiple JREs support

 

Web Start provides the mechanism to specify the JRE version in which the deployed application could be launched. The application developer can specify a list of JREs in the JNLP (Java Network Launch Protocol) configuration file. The Web Start application manager will consider these JREs in the order specified for launching the application. Down the line automatic downloading the JREs will also be provided as a part of the Java Web Start package.

 

Code-signing

 

To avoid impersonating the jars bundled along with the application, the application developer could sign the jars and make it trusted. Jar Signing can be done in the same manner as for applets by using the standard jarsigner tool bundled along with J2SE.

Sandboxing

 

Java Web Start technology takes advantage of the inherent security framework provided by the Java Platform. Applications are by default run in a protective environment (Applet sandbox) with restricted access to local disk and network resources. It allows the user to safely run applications from sources that are not trusted.

 

Desktop integration

 

Web Start applications can be installed in the Desktops or Start Menus (in Windows OS) to provide easy access to the end users.

 

Offline operation

 

Users can work on the installed applications offline, as the entire application is cached in the local computer of the user.

Given these features and the deployment nature of Web NMS Java Client, it would be well acknowledged that Web Start support provides an essential value addition to the Web NMS Client framework.

 

Prerequisites for using Java Web Start

 

The following are the prerequisites for using Java Web Start:

For additional reading on Web Start and its technology you can refer to the Web Start official site launched by Sun Microsystems.

 

Java Web Start Interface for Java Client

 

Web NMS Java Client so far has been supporting Application and Applet client interfaces. With the invent of Java Web Start, Java Client implementation has been extended to support Java Web Start interface and hence extend the value addition that it provides to the end-users.

 

The Java Web Start interface is built over the Application client framework of Java Client. Hence for a user who uses the Java Web Start interface, the user experience will be the same as that of an Application Client, right from startup. The only difference is that, for the first time he/she has to launch it from the initial client web page, same as the initial page used for Applet and HTML Client startup.

 

From a developer perspective the Web Start Interface can be visualized as an application launched from the Web Start Application Manager. All the regulations imposed by the Java Web Start stands applicable to the Web Start launched Web NMS Java Client. Of special note should be the Security restrictions imposed in accessing various resources by Java Web Start. We will discuss about these aspects later in this topic.

 

Accessing Client through the JWS Interface

 

You can access the Java Web Start enabled client in the same mechanism as that of accessing the Applet Client. The steps that are involved in accessing the client through the JWS Interface are:

 

For the first time

 

You have to follow the following steps to connect to the client through Web Start only for the first time.

 

Step 1: Connect with the browser to the host where the Web NMS Server is running. For e.g., it might be http://john:9090, where john is the host (machine) name in which the Web NMS Server is running and 9090 is the port number in which the Web server is bound.

 

Step 2: Please click the Web Start Client button to launch the client through Web Start. If you have installed the Web Start plug-in in your machine, the plug-in will be invoked, which in turn will invoke the Application Client.

 

If you have not installed the Web Start plug-in it will take you to a notification page which will have a link from where you could download the plug-in and install

Step 3: The Application Client Authentication dialog will be prompted, where you have to enter the User name and Password. On successful authentication and connection to the Web NMS server, the client will be launched.

 

 

Figure 3: Authentication Dialog

    1. Note: Due to security restrictions imposed by Web Start, you can only connect to the Web NMS server from where the client jars where downloaded (john in the above example discussed). Trying to connect to any other host will throw an AccessControlException (java.security.AccessControlException).

On Subsequent restarts

 

Once the client is launched through the Web Start for the first time, the plug-in will download all the relevant jar (Java Archive files containing the necessary classes) files related to Web NMS Client from the server and caches them. Hence on subsequent restarts it is just enough to launch the application from the Web Start Application Manager and not connect to the server. This is possible due to the fact that the relevant jars are cached by the Web Start plug-in on the first start of the application.

 

The typical steps in invoking the Application client on subsequent restarts are:

 

Step 1: Invoke the Web Start Application Manager.

 

Step 2: Double click on the "Web NMS Application Client" icon displayed on the desktop of the Application Manager. If you do not see the icon, it implies that you have not downloaded the Application Client from the server even once. In this case please refer to the steps described under the category For First Time.

Step 3: If you had launched the Application client successfully you will be prompted the Authentication Dialog, where you have to enter the User name and Password. On successful authentication and connection to the server, the client will be launched.

User Experience - Difference between Web Start Client and Application Client

 

The end user experience provided on using an Application client launched from Web Start versus launched from a Standalone Application client setup is almost the same, except for some minor differences. The prominent differences are:

Apart from the above listed minor digressions, the end user experience will be the same while using either the Web Start based client or the Application client.

 

Developer Corner

 

In this section we will discuss about developer details needed in customizing and developing over, the Java Web Start interface.

 

Customizing the Login Page

 

While customizing the Web NMS framework, it becomes a essential necessity to customize the login page of the client. Web start interface has two step entry points for logging in, namely:

      1. Web page to launch Web Start Client for the very first time

      2. The Authentication dialog prompted for user login.

Both these entry points can be customized for your needs.

 

Web Page customization

 

There are two aspects, as far as the login web page customization is concerned, which are:

        1. Customizing the initial screen displayed for connecting to the server

        2. Customizing the error page displayed, if Web Start plug-in is not installed.

Customizing the Initial Page

 

As already discussed, when a you want to launch the client, through Java Web Start for the first time, you have to launch it through the browser, similar as launching Applet and HTML Client.

 

Customizing the Error page

 

If you have not installed Web Start on your machine then on clicking the Web Start Client button, an error notification page will be displayed. The contents displayed in this page are generated by a JSP file named WebStart.jsp present under the <Web NMS Home>/jsp directory. If you would like to customize this page please modify the HTML contents generated under the comment tag <!---- to download page - start ----> in the JSP file. Once modified, you should compile the JSP file and restart the server and client for the changes to take effect.

 

It should be noted that, it is this JSP file that gets executed on clicking the Web Start Client button in the web page and generates the .jnlp file that is needed to launch the Web Start plug-in. We will discuss about customizing the JNLP generation later in this chapter.

 

Authentication Dialog customization

 

As a part of the login process the you will be prompted for login details through a Authentication dialog, which is the same as the one displayed on invoking the standalone Application Client. You can follow the same directions as discussed under the Application Client topic for customizing this Authentication Dialog.

      1. Note: If you have implemented your own Authentication Dialog (by extending the class com.adventnet.nms.startclient.WebNMSClient), then make sure to specify the name of the class you have implemented, for the attribute main-class present in the tag <application-desc> in the WebNms.jnlp file (present under the <Web NMS Home>/conf directory). Refer to the section on Customizing the JNLP file to know more about JNLP.

Customizing the JNLP file

 

What is JNLP?

 

The concept of Web Start is centrally built over the protocol termed as Java Network Launch Protocol (JNLP) and its APIs. JNLP is a Web-centric provisioning protocol and application execution environment, for Web-deployed Java Technology-based applications. The main concepts provided by this protocol and API specification are:

The core of any Web Start application is the JNLP file that should be bundled with the application. This file enables the Web Start environment to execute a application in its environment. The JNLP is an XML file that provides the basic elements and descriptions for your application. The purpose of the JNLP file is:

If you would like to know more about JNLP please refer to the JNLP specification provided by Sun Microsystems.

 

JNLP File of Web NMS Client

 

The Web NMS Server on the fly generates a JNLP file to specify the necessary parameters needed to launch Java Client through Java Web Start. The contents generated in this JNLP file are:

If the you want to customize the JNLP file generated for Web NMS Client, it is important to understand the way the JNLP file is generated on the fly. The JNLP file is generated on the first time the user connects to the Server to launch the Client. When the user clicks the Web Start Client button in the browser and launches the Client for the first time, the JSP file named WebStart.jsp (present under the <Web NMS Home>/jsp directory) will be executed, which generates the JNLP file needed to launch the Web Start plug-in.

 

The activities performed by the WebStart.jsp file are:

Customizing the JNLP file

 

As a part of client customization, it would be required even to customize the JNLP file generated to your development needs. Most of the customization can be achieved just by modifying the contents of WebNMS.jnlp file present under the <Web NMS Home>/conf directory.

Developing Java Web Start compliant Applications - A brief guideline

 

The Application developers over the Web NMS Client framework, who intend to deploy Web Start enabled clients, should adhere some rules and guidelines imposed by the Web Start framework. Each of the different client deployment types, namely Applet, Application and Web Start, provides some subtle differences in terms of programming. Understanding these nuances becomes important, if you intend to deploy your customized client in these setups. But it should also be highlighted that the commonalities between them overwhelmingly outweighs the differences.

 

Some of the general guidelines that is good to remember about Java Client Web Start Interface are:

Please refer to the developers web site by Sun Microsystems on Web Start to have more details about this.

 

Retrieving File Resources

 

Accessing files is one of the most commonly executed operation by any application. Since disk operations are prohibited by Web Start you can bundle the files inside the JAR files loaded as a part of the client application and have them accessed from your code.

 

All application resources must be retrieved from the JAR files specified in the resources section of the JNLP file, or retrieved explicitly using an HTTP request to the webserver. It is recommended to store resources in JAR files, since they will be cached on the local machine by the Java Web Start plug-in.

 

The following code example shows how to retrieve images from a JAR file:

    1. .

      // Get current classloader

      ClassLoader cl = this.getClass().getClassLoader();

      // Create icons

      Icon saveIcon = new ImageIcon(cl.getResource("images/save.png"));

      .

The example assumes that the following entry exist in one of the JAR files for the application as: images/save.gif

 

JNLP APIs

 

As Web Start imposes upon some security restrictions, to facilitate developers to access some system based resources, JNLP provides a useful set of APIs. These APIs provides various set of system based Services, which could be accessed by the developers. Some of the services offered are:

You can read more about these APIs and its usage in JNLP API Javadocs.

 

Failover Support for Java Web Start Client

 

Failover support can now be availed by the Java Web Start client. By this it means, whenever the client connection with the server is snapped (due to server failure), the Web Start client immediately avails the failover support and re-establishes connection with the standby server. The chapter on FE Server Failover covers the failover support for Web Start client in detail.

 

Useful Resources

 

You can access some useful resources on Java Web Start in the following URLs

  1. Question Bank on Java Web Start Inteface for Web NMS Java Client

  2. Sun's Official Java Web Start Site

  3. Vamp website

Summary

 

Java Web Start is a new client side technology providing an enhanced methodology of client deployment, with advanced caching, automatic software upgrade, security sandbox and other very good features. Web NMS Java client being a client-server based application providing Applet and Application based interfaces, naturally stands to gain by this new technology. The Web Start enabled Java client provides users with a very good value addition, with the possibility of being one of most desired client deployment scenario.

 


Copyright © 2013, ZOHO Corp. All Rights Reserved.