We have seen on the first tutorial how the application is deployed in the
client side.
Now, we will see how to create the JWS application.
We will begin from an existing application that uses two external API's :
Jogl (OpenGL)
and NativeFmodEx (FMOD
Ex).
You will see how use jws for deploying your applocation with these two API's.
The resulting jws application is here :
Geometry
The example used for this tutorial is taken from NativeFmodEx (a Java port of
an example included with FMOD Ex).
This example is composed of :
NativeFmodEx API : NativeFmodEx.jar, NativeFmodEx.dll and fmodex.dll //and libraries for Linux
The difficulty here is to link the two requiered API's, especially the
libraries that depends on the target platform.
In this example, we uses two API's that uses libraries. To use them, your
application need to all permission.
To obtain these permissions, your need to sign all jars you will use.
First thing to do is to generate a certificate. This will indicates where the
application come from (compagny, location ...). The certificate is used to
authentify the application.
To generate this certificate, use the
keytool
utility from the jdk.
keytool |
keytool -genkey -keystore %SIGN_NAME% -alias %SIGN_NAME% |
Replace %SIGN_NAME% by your key name ( ~ "certificate name").
Certificate
Keytool utility will generate a file named %SIGN_NAME%
, storing the certificate and the key.
Now you have a certificate, you can sign your jars.
Use for this the
jarsigner
tool, also in the jdk.
This is used to verify the signature (authenticity) and integrity of the jar
during its use.
jarsigner |
jarsigner -keystore .\%SIGN_NAME% -storepass %PASS% -keypass %PASS% %JAR%.jar %SIGN_NAME% |
Replace %SIGN_NAME% by your key name ( ~ "certificate
name").
%PASS%
by your key password.
%JAR%
by the filename of the jar to be signed.
A jnlp file is an xml file in wich you put all informations about your application.
In the tag information, you can give your personal information, the application
description ...
The other tags are used to give informations for running the application.
Here are the three jnlp file used to run the example :
JWS-Tutorial02.jnlp |
<?xml version="1.0" encoding="utf-8"?> |
NativeFmodEx.jnlp |
<?xml version="1.0" encoding="utf-8"?> |
Jogl.jnlp |
<?xml version="1.0" encoding="utf-8"?> |
The tag security define the secutity level of
the aplication, here we need all permissions (because of use of native libraries).
In this case, all jars must be signed.
The tag resources list all resources necessary for running the application. A
resource can be a jar (tag resources), a
library (tag nativelib), an extension (tag
extension).
To use a library, you should packed it into a signed jar (create a jar, then
sign it). An extension is a sub jnlp file. It is commonly used for external APIs,
code shared between differents applications ...
First, you need to put the jnlp and the jar file in the location refered by
the fields codebase and
href (declared in the jnlp file).
To execute the application from any of your page, add just a classic html link
that points toward the jnlp file. In case of use of multiple jnlp files, points
toward the main jnlp file.
HTML link |
<A HREF="http://www.mysite.com/JWS/MyApplication.jnlp"></A> |
The server hosting the application must associate the
MIME type
application/x-java-jnlp-file with the jnlp
extension.
MIME type tell the browser which application should be used to execute the file.
When this association is done, executing the application under Firefox look like
:
Association
What can we do if we can't associate MIME
type ?
The association can be done using php. Just
add these few lines at the beginning, and change the extension of the jnlp file
to *.php.
MIME Association with PHP |
<? |
Change FILE_NAME by the original file name of
your jnlp file.
Last modified on 01/07/2010 | |
Copyright © 2004-2010 Jérôme JOUVIE - All rights reserved. | http://jerome.jouvie.free.fr/ |