41 | | URL of the demo deployment: http://asteasolutions.net/~jordan/jws-demo/sophie2author.html |
| 41 | |
| 42 | == Demo == |
| 43 | URL of the demo deployment: http://asteasolutions.net/~jordan/jws-demo/sophie2author.html. |
| 44 | |
| 45 | === Introduction === |
| 46 | To prepare an application for deployment via Java Web Start, you write a JNLP file (JWS reads it to know what to do) and package the appilcation into .jar files. Then you put the JNLP file and the .jar files into a folder that is served by a web server.[[BR]]The JNLP file describes the application. It tells JWS what's the application's name, where the aplication's .jar files are located and more. |
| 47 | |
| 48 | == Deploying Sophie 2 via Java Web Start == |
| 49 | 1. Compile Sophie 2 into .jar files. |
| 50 | 1. Put the .jar files into a temporary directory. |
| 51 | 1. Prepare a JNLP file (e.g. by customizing the attached example) and put it in the temporary directory. |
| 52 | 1. Generate a keypair and a self-signed certificate by using {{{keytool -genkeypair}}}. ''This step is done only once. The generated keypair and certificate are used many times.'' |
| 53 | 1. Sign the {{{org.sophie2.launcher}}} and {{{org.sophie2.author}}} .jar files, one by one, using the {{{jarsigner}}} command: {{{jarsigner <file> mykey}}}. |
| 54 | 1. Copy the contents of the temporary directory to a suitable location on the web server. |
| 55 | |
| 56 | |
| 57 | == How launching works - step by step == |
| 58 | (some details are omitted) |
| 59 | 1. The user clicks on a link in a web page. The link points to the JNLP file. |
| 60 | 1. JWS loads the JNLP file and interprets its contents. |
| 61 | 1. JWS loads the {{{org.sophie2.launcher}}} and {{{org.sophie2.author}}} bundles (.jar files) as instructed by the JNLP file. |
| 62 | 1. JWS starts the application by executing the {{{main(String[] args)}}} method in the {{{org.sophie2.launcher.JavaWebStartMain}}} class, passing it the arguments prescribed by the JNLP file. |
| 63 | 1. The launcher, now running, reads the list of bundles that comprise the Author edition of Sophie 2 from the {{{author.bundles.config}}} file (found in the {{{org.sophie2.author}}} .jar file). |
| 64 | 1. The launcher creates a temporary directory that Felix will use as its bundle cache. |
| 65 | 1. The launcher starts Felix and passes it the list of bundles and the URL's where they can be found. |
| 66 | 1. Felix downloads the bundles and activates them, thus starting the application. |
| 67 | |
| 68 | == Limitations and expected problems == |
| 69 | * Native libraries are supported by Java Web Start, however, what really matters for Sophie 2 is Felix's support for them. |
| 70 | |
| 71 | == Notes == |
| 72 | * The web server hosting the JNLP file must be configured to serve {{{.jnlp}}} files with the {{{application/x-java-jnlp-file}}} MIME type. |
| 73 | * An example JNLP file is attached to this wiki page. |
| 74 | * Java Web Start downloads and caches .jar files. Felix downloads and caches .jar files too. The two cache mechanisms don't play well together. |
| 75 | * Felix needs unrestricted access to its bundle cache directory in order to function properly. That's why the JNLP file of Sophie 2 Author requests the {{{all-permissions}}} trusted execution environment. This trusted environement gives the application full access to the user's computer. There's an additional advantage to running in the trusted environment: the user doesn't get annoyed by security dialogs constantly popping up to request permission. |
| 76 | * For an application to be running in the {{{all-permissions}}} trusted execution environment, its .jar files must be signed. |