Netra j 2.0 Administrator's Guide

Chapter 10 Dynamically Loading Applications

JavaOS supports dynamic delivery of the user's main application to the JavaStation system by a web (HTTP) server when the JavaStation boots. This chapter describes how to set up an application to be dynamically loaded.

For more information on the JavaStation boot sequence, see Chapter 8, Booting the JavaStation Using Solaris.

Overview

There are two methods for loading an application. One is to configure a single "fixed" application to be loaded and launched in the JavaStation boot. The other is to provide each client with a dialog window containing a list of applications to choose from. In the second case, JavaOS passes control to Application Launcher to do the following:

Applications are bundled as JAR or zip archives and are referenced by URLs. Application Launcher uses the java.util.zip classes to download and expand an application archive into a virtual RAM-based file system on the JavaStation. Since the application archive is referenced by a URL, it can reside anywhere on the network.


Note -

Application Launcher does not provide an environment to enable multiple applications to run on a single virtual machine. Only one application can run at a time.


Setting Up Applications for Dynamic Loading

The following procedures describe how to load and launch an application using the methods described in the previous section.

To Create an Archive

Applications are typically made up of class, text, graphics, HTML, and property files.

Many application hierarchies are organized so that all the class files are in the classes directory and everything else is in the lib directory. This policy is enforced for dynamic loading to ensure the application classes can be found and added to the system CLASSPATH.

  1. Verify that your project directory contains both a classes and a lib directory and that all application classes reside in the classes directory.

  2. Remove any unnecessary files from the classes and lib directories.

    It is important to conserve memory on the JavaStation system.

  3. Create a JAR file containing the classes and lib directories.

    The JAR (Java Archive) utility is provided in JDK software. Use the following syntax: jar -cf archive_name classes lib

    For example, to create a JAR file of the HotJava Views application:


    % jar -cf hotjava.jar classes lib
    


    Note -

    You can also use the zip utility (not provided in the JDK) to create archives.


  4. Place the archive in a directory that is accessible to the HTTP server.

To Launch a Single Application at Login
  1. Create the application archive.

  2. Set the JavaOS properties listed in Table 10-1

    Table 10-1 JavaOS Properties Required to Load a Single Application

    Property  

    Description 

    javaos.mainProgram

    The name of the application's main class.

    javaos.mainZip

    The name of the application archive. The archive name is absolute. Example: http://amber.eng/~fredw/javaos/hotjava.jar.

    javaos.mainHomeprop

    The name of the property specifying the application's root directory. For example, HotJava Views uses the hotjava.home property to specify its root directory. Other applications may have different property names. When the virtual file system is created, this property is set to enable the application to find its files.

    For example, to launch HotJava Views, you would set the following JavaOS properties. In the following example, amber.eng/~fredw/javaos are the host, user, and directory names.


    -djavaos.mainProgram=sunw.hotjava.Main 
    -djavaos.mainZip=http://amber.eng/~fredw/javaos/hotjava.zip 
    -djavaos.mainHomeprop=hotjava.home
    

    JavaOS properties are delivered to the JavaStation in the DHCP options or in a file referenced in the DHCP options. For complete instructions on setting JavaOS properties, see Chapter 9, Setting JavaOS Properties .

To Provide a Dialog Window With a Pick List of Applications
  1. Create an archive for each application.

  2. Create an application tag file.

The application tag file is an HTML file containing information (a "tag") on each application archive. Application Launcher parses the application tag file and presents a window displaying a list for the user to select from.

Each application tag contains the attributes listed in Table 10-2.

Table 10-2 Application Tag Attributes

Attribute 

Description 

code

The name of the application's main class.

name 

The name to be displayed in the Application Launcher list window. This attribute is optional. By default, the path to the archived zip file will be displayed in the list. 

archive

The name of the application archive. The archive name can be either relative (hotjava.jar) to the directory containing the application tag file or absolute (http://amber.eng/~fredw/javaos/hotjava.jar).

An application tag can also have the parameters listed in Table 10-3.

Table 10-3 Application Tag Parameters

Parameter 

Description  

homeprop

The name of the property specifying the application's root directory. For example, HotJava Views uses the hotjava.home property to specify its root directory. Other applications may have different property names. When the virtual file system is created, this property is set to enable the application to find its files.

args

Enables you to pass an arbitrary list of arguments to the main() of your application. The list is separated with a space, just as on the command line.

The following is a sample application tag file.


<DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <title>Applications</title>
  </head>
  <body>
      <h1>Applications</h1>

<application code="sunw.hotjava.Main" name="HotJava Browser" archive="hotjava.jar">
<param name="homeprop" value="hotjava.home">
<param name="args" value="http://java.sun.com/">
</application>

<application code="sunw.hotjava.Main" name="HotJava Views" archive=jdt/html/classes/Selector.jar>
<param name="homeprop" value="hotjava.home">
<param name="args" value="http://http_server/apps/selector.init">
</application>

<application code="sunw.applet.AppletViewer" name="AppletViewer" archive="appletviewer.zip">
<param name="args" value="http://http_server/taos/taos.html">
</application>

  </body>
</html>

  1. Place the application tag file in your HTTP server's document root directory or a subdirectory under it.

  2. Use the JavaOS property javaos.apps to specify the location of the application tag file. For example:


    -djavaos.apps=http://amber.eng/~fredw/javaos/applauncher.html

    JavaOS properties are delivered to the JavaStation in the DHCP options or in a file referenced in the DHCP options. For complete instructions on setting JavaOS properties, see Chapter 9, Setting JavaOS Properties .