Prepare the Application Client run-time dependency component for Java Web Start

For a J2EE application client application and or Thin application client application to be launched using Java Web Start (JWS), an Java Runtime Environment that IBM provides, the library JAR files and properties files bundled in Application Client for WAS must be installed in the JWS. This article provides the steps to build the Application Client run-time dependency component from an Application Client installation. It is packaged as a Web Archive Resource (WAR) file that can be installed in an Application Server.

 

Before you begin

Install the Application Client for WAS for the platform to which the client application deploys. If there is a requirement to deploy the client application to multiple platforms, the Application Client run-time dependency component must be built separately for each platform that client application supports.

For example, if the client application deploys to both the Windows platform and Linux platform, follows the steps for this task to build the Application Client run-time dependency component for Windows on a Windows platform machine with the Application Client for WebSphere Application Server for Windows installed. Now, repeat the steps for this task to build the Application Client run-time dependency component for Linux on a Linux platform machine with the Application Client for WebSphere Application Server for Linux installed.

 

Procedure

  1. Install the Application Client for WebSphere Application Server for the client application supported operating systems. Install Application Client in the C:\Program Files\IBM\WebSphere\AppClient directory.

  2. Change the directory to the installation bin directory. See the following example for help

    CD C:\Program files\IBM\WebSphere\AppClient\bin
    

  3. Run the buildClientRuntime tool to generate the Application Client run-time JAR file in a temporary directory which contains the Java 2 Runtime Environment, Application Client run-time properties, the SSL KeyStore and TrustStore file, and the Application Client run-time library JAR files. See the following example for help

    buildClientRuntime C:\WebApp1\runtime\WASClient6.0_windows.jar 
    

    If you are building an Application Client run-time JAR file only for serving Thin application client applications and not for J2EE application client applications, one can reduce the size of the generated JAR file by not including the Application Client run-time library JAR files. An extra parameter is passed to the buildClientRuntime tool, as the following example shows

    buildClientRuntime C:\WebApp1\runtime\WASClient6.0_windows.jar 
                       buildThin
    
    

  4. Copy the WebSphereClientRuntimeInstaller.jar file to the same location of the JAR file generated in the previous step. This JAR file is located in the JWS directory of the WebSphere Application Server clients installation. See the following example for help

    copy ..\JWS\WebSphereClientRuntimeInstaller.jar   C:\WebApp1\runtime
    

  5. Sign the JAR files created from the previous steps, using the Java 2 SDK jarsigner utility, as the following example shows:

    cd C:\WebApp1\runtime
    
    jarsigner -keystore myKeystore -storepass myPassword 
                    WASClient6.0_windows.jar myKeyAliasName
    
    jarsigner -keystore myKeystore -storepass myPassword 
                    WebSphereClientRuntimeInstaller.jar myKeyAliasName
    
    

    1. This step also requires you to create a keystore file, such as myKeystore.

    2. You must also create a self-signed certificate for the myKeystore file. For more information, see the topic, "Creating self-signed personal certificates."

      Note: When running the JAR signer tool on HP platforms, add the -J"-Xmx256m" flag to the jarsigner command to increase the available heap size and prevent the error, OutOfMemoryError. See the following example for help

      jarsigner -J"-Xmx256m" -keystore myKeystore -storepass myPassword 
                      WebSphereClientRuntimeInstaller.jar myKeyAliasName
      

  6. Create an Application Client run-time installer JNLP descriptor file or a JavaServer Pages (JSP) file if it is generated dynamically in the same temporary directory as previous step. See the sample JNLP file shown in the Example section of this topic.

  7. Package the two signed JAR files and the Application Client run-time installer JNLP descriptor file into a WAR file. This WAR file is packaged into an EAR file that can be deployed to an Application Server.

 

Result

Your Web application is ready to serve the Application Client run time and the JRE environment.

 

Example

<%--
This is an Installer JNLP
It will download two .jars:
WebSphereClientRuntimeInstaller.jar - includes the installer utility
WASClient6.0_<platform>.jar - the client runtime JRE image

The installer will unzip the client runtime jar on the client machine, and register
it with Java Web Start

--%>
<%! private final String description="WebSphere Client 6.0 Runtime JRE";
// The version here is (WAS based) JRE version - as to be managed on the client
private final String JREversion="WASclient6.0";%>
<%
// locally declared variable
String url=request.getRequestURL().toString();
String jnlpCodeBase=url.substring(0,url.lastIndexOf('/'));
String jnlpRefURL=url.substring(url.lastIndexOf('/')+1,url.length());

// Need to set a JNLP mime type - if Web Start is installed on the client,
// this header will induce the browser to drive the Web Start Client
response.setContentType("application/x-java-jnlp-file"); 1
response.setHeader("Cache-Control", null);
response.setHeader("Set-Cookie", null);
response.setHeader("Vary", null);

// An installer must reply with the version number for a given install
if (response.containsHeader("x-java-jnlp-version-id"))
response.setHeader("x-java-jnlp-version-id", JREversion); 2
else
response.addHeader("x-java-jnlp-version-id", JREversion);


%>
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for <%=description %> -->
<jnlp
spec="1.0+" <%--
Automate the code base response --%>
codebase="<%=jnlpCodeBase%>"
href="<%=jnlpRefURL%>">
<information>
<title><%=description%></title>
<vendor>IBM</vendor>
<icon href="icon.gif">
<description><%=description%></description>
<description kind="short"><%=description></description>
<description kind="tooltip"><%=description></description
<offline-allowed/>
</information>
<security>
</all-permissions>
</security>
<resources>
<j2se version="1.4+"/><%-- The installer can use any 1.4 JRE --%> 3
<jar href="WebSphereClientRuntimeInstaller.jar" main="true"/> 4

<%-- JRE version registration with Web Start --%>
<property name="com.ibm.websphere.client.jre.version" value="<%=JREversion%>"/> 5

</resources>
<resources os="Windows"> 6
<jar href="windows/WASClient6.0_windows.jar"/> 7

<%-- relative path of the jre executable --%>
<property name="com.ibm.websphere.client.jre.launch.java"
value="java\jre\bin\java.exe"/> 8
<resources os="Linux">
<jar href="linux/WASClient6.0_linux.jar"/>

<property name="com.ibm.websphere.client.jre.launch.java" value="java/jre/bin/java"/>
</resources>
<installer-desc />
</jnlp>

  1. Specifies that the file is a JNLP mime type so that the browser can process the JNLP file.

  2. Specifies the exact version of this Application Client run-time dependency component in the response by setting the HTTP header field: x-java-jnlp-version-id.

  3. Specifies the required JRE version to run the installer program.

  4. Installer WebSphereClientRuntimeInstaller.jar file, which contains the ClientRuntimeInstaller class.

  5. Specifies a system property that defines the version of Application Client run-time dependency component. This version is registered to the JNLP client.

  6. Specifies resources for a particular platform. Each supported client application platform needs its own separate JAR file.

  7. Specifies the Application Client run-time dependency component JAR file.

  8. Specifies the program to call that starts a JVM for the client application.

 

What to do next

Preparing Application Client run-time library component for Java Web Start.

 

See also


buildClientRuntime tool
ClientRuntimeInstaller class

 

See Also


Web applications

 

Related Tasks


Preparing Application Clients run-time library component for Java Web Start