How To - Java Web Start for Alma
Java Web Start is a technology to deploy applications to end-users
through a Web Browser Plug-in. By clicking a link the user can install
and run applications on their local host.
Java Web Start
is smart enough to download newer versions of an application from the
server whenever
they are available.
The Acs team uses it to deploy a Java-only Acs and various Acs tools
(see AcsWebStart).
I. Porting
From Sun’s official FAQ:
Do I need to change my
application to work with Java Web Start?
If your application is written to the Java 2 platform, and is delivered
as a set of JAR files1,
there should be no need to revise your application.
Make sure that all your application resources (such as images and
resource bundles, for example) are retrieved from a JAR file2, since Java
Web Start launches an application by invoking the public static
void main(String[] args)
method.
And if your application needs unrestricted access to the system, (for
example, network or disk access), you will need to sign your code.3
- All required jars will need
to be listed in a jnlp-file. See II below.
- Put simple: Do not use java.io.File,
instead use getClassLoader.getResource()
For a full-flegded solution, see the resource loading
toolkit Rachel in the References section below
- Explained in III below
II. Preparing a Jnlp file
The jnlp-file tells the Web Start Plug-in, besides some descriptive
info,
what jars need to be loaded from the server
Example: SuperApp.jnlp
<?xml version="1.0" encoding="utf-8"?>
<jnlp
spec="1.0+"
codebase="http://www.example.com/path/to/superapp">1
<information>
<title>Shortdescription</title>
<vendor>Us, the Alma Team</vendor>
<description>Longdescription shown in Web
Start Manager</description>
<offline-allowed/>2
</information>
<security>
<all-permissions/>3
</security>
<resources>
<j2se version="1.4+"/>
<jar href="lib/myApplication.jar"/>4
<jar href="lib/someLibrary.jar"/>
<property name="SuperApp.isWebstarted"
value="true"/>5
<extension href="./Libraries.jnlp">6
<ext-download
ext-part="Libraries"/>
</extension>
</resources>
<application-desc
main-class="com.example.SuperApplication">
<argument> -doExample
</argument>
<argument> -verbose
</argument>
</application-desc>
</jnlp>
The example is pretty straightforward, however, some points require
attention:
- The codebase must match the location of the jnlp-file itself (due
to how Web Start works). If this jnlp-file cannot be found under
www.example.com/path/to/superapp/SuperApp.jnlp
, it
will not work.
- If your app doesn't require a network connection to run, put in
<offline-allowed/>
- If your app needs access to the filesystem or to servers other
than the one it was loaded from, put in
<all-permissions/>**
- The jar
myApplication.jar
that contains the
main-class com.example.SuperApplication
has to be first
in the sequence of <jar>
s.
- You can define your own system property values as you like. Most
java.* system properties are write-protected however for security
reasons.
- If you have many libraries and if you like it modular, use
sub-jnlp-files and include them as
<extension>
s
** In that case you'll also
need to sign the jars. See III below.
III. Preparing the jars
If your app is considered security-critical by Java Web Start, you are
required to sign your application jar files.
Things to consider:
- All jars specified in the same jnlp-file must use the same
security signature1
- Each of the jars must have one and only one signature
Viewing existing signatures
To get information about the security signatures of one or more jars,
use the command acsJarSignInfo coming with ACS.
> acsJarSignInfo
Scanning all jars in this directory tree for signatures...
1 (ESO) in ./acscomponent.jar
1 (ESO) in ./acsjlog.jar
1 (ESO) in ./archive_database.jar
1 (ESO) in ./archive.jar
1 (ESO) in ./archive_xmlstore_if.jar
1 (ESO) in ./cdbDAL.jar
Each jarfile in this directory has 1 signature and the names of the
used certificates (ESO) are all the same - looks healthy.
Signing
To sign jars yourself, you first need a keystore. You can create one
using the Java keytool in interactive mode:
> keytool -genkey -keystore MyKeyStore -alias
SuperAppDeveloper
Second, you sign each jar using the Java jarsigner:
> jarsigner -keystore MyKeyStore -storepass
MySecretPassword myApplication.jar SuperAppDeveloper
- If this imposes a problem,
think of modularizing your jnlp files into sub-jnlp-files using the
<extension>
tag.
IV. Create a nice Html page
... with a link to SuperApp.jnlp
V. Troubleshooting
Make your Java Web Start Manager log its output to a file. This will be
valuable info for troubleshooting.
The following jnlp-file will launch the Manager so you can edit its
configuration:
<?xml version="1.0" encoding="utf-8"?>
<player/>
References
Java Web Start Home : http://java.sun.com/products/javawebstart
Official FAQ : http://java.sun.com/products/javawebstart/faq.html
Unofficial FAQ : http://lopica.sourceforge.net/faq.html
Resource Loading Toolkit : http://rachel.sourceforge.net
AcsWebStart : http://www.eso.org/projects/alma/AcsWebStart
Version
|
Author
|
Changes
|
|
|
|
|
|
|
2009-11-27
|
Marcus Schilling
|
Some info was outdated
|
2004-08-05
|
Marcus Schilling
|
Created
|