The following procedures describe how to load and launch an application using the methods described in the previous section.
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.
Verify that your project directory contains both a classes and a lib directory and that all application classes reside in the classes directory.
Remove any unnecessary files from the classes and lib directories.
It is important to conserve memory on the JavaStation system.
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
You can also use the zip utility (not provided in the JDK) to create archives.
Place the archive in a directory that is accessible to the HTTP server.
Create the application archive.
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 .
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>
Place the application tag file in your HTTP server's document root directory or a subdirectory under it.
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 .