Top
||
Section Contents
||
Permuted Index
SavaJe OS
1.1.0
This document discusses packaging and running applications on SavaJe OS , including the following topics:
The best way to package applications is to use JAR files.
For example, consider the application demo.MyDemo
, where main()
is contained in the file demo/MyDemo.class
. MyDemo
also uses
demo.stuff.AnotherClass
and demo.util.Tool
. The following tree
shows the package hierarchy for demo.MyDemo
:
demo |-- MyDemo.class |-- stuff | `-- AnotherClass.class `-- util `-- Tool.class
To package this application in a JAR file, create a manifest file
(MyDemo.mf
in this example) containing the line:
Main-Class: demo.MyDemo
Then, from the parent directory of demo, run the jar command
jar cvmf MyDemo.mf MyDemo.jar demo
Now, you should be able to execute the resulting JAR file using the java command (on non- SavaJe OS platforms):
java -jar MyDemo.jar
On a
SavaJe OS
platform (after you've copied MyDemo.jar
to the compact flash and
inserted the compact flash into the computer), you should be able to run
the application with the following commands (assuming that MyDemo.jar
is located in the directory /cf0/users/me
:
lsh% cd /cf0/users/me lsh% run MyDemo.jar
or (from anywhere)
lsh% run /cf0/users/me/MyDemo.jar
You can also copy JAR files to the /ramfs
file system
(e.g., /ramfs/users/me/MyDemo.jar
) and
run them from there.
If you need to repackage an application that consists of multiple
JAR files, you do not need to disturb the current JAR files.
Simply create a new JAR file that contains only a MANIFEST
file with the Main-Class
attribute specifying the class that
contains the main()
method and
the Class-Path:
attribute listing the JAR files
that should be searched.
For example, if an application is split into two JARs,
you could create a file EmptyJar.mf
that contains
the lines
Main-Class: AppMain Class-Path: AppMain.jar another.jar
Create a new JAR file that contains only the manifest information:
host% JAR -cvmf EmptyJar.mf EmptyJar.jar
Place EmptyJar.jar
and the other JAR files in the same
place and
Run the application with
% cd somewhere % run [-nosm] EmptyJar.jar
You may need to use the -nosm
option of the run
command if
the security policy is not appropriate.
Copy JAR files to a directory being served by httpd. The requirements on the JAR file are the same as for local JAR files.
By default,
SavaJe OS
installs a security manager with fairly restrictive
permissions. (To see the default permissions, enter the command
policy dump
.) See
policy(shell)
.
Some applications may try to read or write files on the compact
flash or make socket connections. If you get a security exception
while running an application, try using the -nosm
option of
the
run(shell)
command.
When class files are loaded, they are run through a bytecode
verifier. Some applications compiled with older versions of
Java compilers may fail the current bytecode verification. If
this is the case, try using the -noverify
option of the
run(shell)
command.
The SavaJe OS operating system supports FAT12 and FAT16 file systems on compact flash with VFAT long filename extensions. Short filenames with capital letters will cause problems if created on a PC. There are two solutions:
You can run classes or executable JAR files that reside in local storage.
The following example demonstrates running a class from the compact flash:
lsh% cd /cf0/apps lsh% ls Hello.class Hello.class lsh% Hello Hello, world!
The following example demonstrates running an executable JAR from
/ramfs/tmp
:
lsh% cd /ramfs/tmp lsh% ls Hello.jar Hello.jar lsh% Hello.jar Hello, world!
base
to set the class search path
Use
set(shell)
to specify a list (via the shell variable base
) of URLs to search for
classes.
The shell variable base
is analagous to CLASSPATH
in other
Java environments.
The URLs included in base
can be either directories (denoted
by a trailing slash) or JAR or zip files (no trailing slash).
For example,
lsh% set base=file:///ramfs/users/albc/,http://192.168.0.237/MyApp.jar,http://chopin/classes/ lsh% run MyApp
sets the search path to the directory (note the trailing slash) /ramfs/users/albc/
,
the JAR file MyApp.jar
served by host 192.168.0.237
,
and the directory classes
served by the host chopin
.
Use
set(shell)
to set base
to the URL where a remote application resides
(JAR files or class directory). Once base
is set, you should be able
to run the application normally.
If you are trying to run a remote application that consists of a large JAR file and you are having trouble getting it to run on a SavaJe OS platform, try running the application locally first to make sure the problem is not a result of a networking problem. There are several alternatives:
Copy the file to /ramfs/tmp
:
Setlsh% cat http://server/app.jar > /ramfs/tmp/app.jar
base
to the JAR file in /ramfs/tmp
and run the application:This will use up more RAM, but depending on the size of the JAR file, you may still be able to run the application.lsh% set base=file:///ramfs/tmp/app.jar lsh% run MyApp
If you have a compact flash card, you can copy the JAR file to /cf0
,
set base
to the JAR file and run the application.
You can also extract the JAR file into a directory (e.g., app
) on
the web server, then set base
to this directory using this command:
and then run the application. Note that the trailing slash (lsh% set base=http://server/app/
/
) is required
when setting base
to a directory.
If you need to load an application as if it were part of
the platform (a bootstrap or extension),
you can place the application JAR file in the
jre/lib/ext
directory of either
the /cf0
or /apps
partition.
See
romfs(doc)
for information about adding files to the /apps
partition.
For information about creating JNLP files and adding icons to the desktop, see jnlp(shell) .
app_env(doc)
jnlp(shell)
policy(shell)
romfs(doc)
run(shell)
set(shell)