JavaStation Client Software Guide

Setting Up Dynamic Delivery of an Application

This section describes the procedures for setting up an application to be delivered dynamically to JavaStation computers at bootup.

You can configure dynamic delivery in two ways:

Figure 5-1 AppLoader Window on the JavaStation Screen

Graphic


Note -

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


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

    Applications typically comprise 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.

  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 utility is provided in the Java Developer's Kit(TM) (JDK(TM)). 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 Set Up Dynamic Delivery
  1. Create an archive of the application.

    An application archive can be a zip or JAR file. See "To Create an Archive".

  2. Determine whether you will deliver a single "fixed" application or a dialog with a list from which the user can select an application.

To Deliver a Single Application
  1. Create the application archive.

    See "To Create an Archive".

  2. Determine how your application will access ancillary files as it runs on the JavaStation computer, and set the javaos.mainHomeprop property if needed.

    Many applications need to access ancillary files at runtime (such as images and configuration files). Typically, applications access these files relative to their installation directory. For example, when HotJava Browser runs on Solaris, it determines the environment variable HOTJAVA_HOME and then sets the hotjava.home property to that value. HotJava then uses this property to locate the additional files it needs at runtime.

    In the JavaOS environment an application is installed in the ROM file system at boot time, and there is no startup script to determine where the application resides. To prevent you from having to hard-code the location into your application, the JavaOS software sets a property of your choosing to this location. You provide the name of the property in the JavaOS property javaos.mainHomeprop. Thus, for HotJava Browser, the property is the hotjava.home property and it is specified as follows:


    -djavaos.mainHomeprop=hotjava.home

    At boot time, the JavaOS software sets this property (hotjava.home) to where the application is "installed" in the ROM file system. Internally your application may use this property to determine the location of a data file. For example, HotJava Browser could use the hotjava.home property to locate an image file (error checking removed for brevity):


    String imagePath = System.getProperty("hotjava.home") +File.separator + "image.gif";

    As you set up an application for dynamic delivery, determine whether you will need to use the javaos.mainHomeprop mechanism at all - maybe your application does not have ancillary files, or maybe you can use Class.getResource() to find resources. If you do use this mechanism, pick the property name for the JavaOS software to set, and use that property internally.

  3. Set the JavaOS properties listed in the following table.

    Table 5-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/javaos/hotjava.jar.

    In the following example, the JavaOS properties listed in the preceding table and javaos.mainHomeprop are set to launch HotJava Views. In this example, amber.eng/javaos are the host and directory names.


    -djavaos.mainProgram=sunw.hotjava.Main 
    -djavaos.mainZip=http://amber.eng/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 4, JavaOS Properties .

To Set Up AppLoader With a List of Applications
  1. Create an archive for each application.

    See "To Create an Archive".

  2. Create an application tag file.

    The application tag file is an HTML file containing application "tags," which are sets of information on each application. AppLoader parses the application tag file and presents a window displaying a list of applications for the user to select from.

    Each application tag must contain the attributes listed in the following table.

    Table 5-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, AppLoader displays the path to the archived zip file. 

    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/javaos/hotjava.jar).

    An application tag can also have the parameters listed below.

    Table 5-3 Application Tag Parameters (Optional)

    Parameter 

    Description  

    homeprop

    The name of the property specifying the application's root directory. This parameter sets the javaos.mainHomeprop property. See "To Deliver a Single Application " for more information.

    args

    Enables you to pass an arbitrary list of arguments to the main() of your application. Within the list, items are 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>

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

  4. Use the JavaOS property javaos.apps to specify the location of the application tag file.

    For example:


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