Distribuzione di un'applicazione basata su Eclipse con Java Web Start

Applications built on Eclipse can be deployed using Java Web Start.

Java Web Start è una tecnologia di distribuzione delle applicazioni che offre la possibilità di avviare applicazioni complesse con un semplice clic dal browser Web.

I prerequisiti per avviare Eclipse da Java Web Start sono:

La seguente procedura descrive come configurare un sito Java Web Start che gestisce un'applicazione RCP basata su funzioni.

Step 1, creating a wrapper feature

Step 2, exporting the wrapper feature and the startup.jar

Nota: Before proceeding with this step make sure to have a key store available. Eclipse does not provide any facility to create key stores. You can use the keytool application that comes with the JDK. Inoltre, assicurarsi che l'Eclipse di sviluppo sia in esecuzione su Java SDK invece di JRE. Se questo vincolo non viene rispettato, la firma del jar terminerà in errore.

Step 3, creating the main JNLP file

Nei file JNLP viene descritta un'applicazione Java Web Start. They replace the eclipse.exe and the config.ini files by some equivalent mechanism. Ad esempio, JNLP ha propri meccanismi di controllo della schermata iniziale, modalità di passaggio dei parametri e definizioni dell'applicazione.

Quando si esegue l'esportazione, vengono creati tutti i file JNLP semplici e l'utente deve solo scrivere il file principale che controlla l'applicazione. Dal momento che il file principale presenta molte parti comuni a tutte le applicazioni, si consiglia di iniziare con il seguente modello con documentazione incorporata.

Sul sito che gestisce l'applicazione, il file si deve trovare nella stessa cartella di startup.jar. Dopo aver modificato questo file, l'applicazione sarà pronta per l'esecuzione.

<?xml version="1.0" encoding="UTF-8"?>
<jnlp 
    spec="1.0+" 
    codebase="http://myCompany.org/jnlpServer" 
    href="mail.jnlp"> <!-- URL to the site containing the jnlp application. It should match the value used on  export. Href, the name of this file -->
  <information>
    <!-- user readable name of the application -->
    <title> Mail Application </title>  
    <!-- vendor name -->
    <vendor>My company</vendor>
    <!-- vendor homepage --> 
    <homepage href="My company website" /> 
    <!-- product description -->
    <description>This is a mail client</description> 
    <icon kind="splash" href="splash.gif"/>
  </information>
 
  <!--request all permissions from the application. This does not change-->
  <security>
    <all-permissions/>
  </security>
 
  <!-- The name of the main class to execute. This does not change-->
  <application-desc main-class="org.eclipse.core.launcher.WebStartMain">
    <argument>-nosplash</argument>
  </application-desc>
 
  <resources>
    <!-- Reference to the startup.jar. This does not change -->
    <jar href="startup.jar"/>
 
    <!-- Reference to all the plugins and features constituting the application -->
    <!-- Here we are referring to the wrapper feature since it transitively refers to all the other plug-ins  necessary -->
    <extension 
        name="Wrapper feature"
        href="features/Wrappering_1.0.0.jnlp"/>
 
    <!-- Information usually specified in the config.ini -->
    <property 
        name="osgi.instance.area" 
        value="@user.home/Application Data/mail"/>
    <property 
        name="osgi.configuration.area" 
        value="@user.home/Application Data/mail"/>
        
    <!-- The id of the product to run, like found in the overview page of the product editor -->
    <property 
        name="eclipse.product" 
        value="mail.product"/>
  </resources>

  <!-- Indicate on a platform basis which JRE to use --> 
  <resources os="Mac">
    <j2se version="1.5+" java-vm-args="-XstartOnFirstThread"/>
  </resources>
  <resources os="Windows">
    <j2se version="1.4+"/>
  </resources>
  <resources os="Linux">
    <j2se version="1.4+"/>
  </resources>
</jnlp>

Tip: once you have created this file, you can store it in the wrapper feature in the same folder than the startup.jar, such that on every export you will get the complete structure.

Applicazione basata su plugin

Anche se un'applicazione RCP non utilizza funzioni, è possibile usare Java Web Start.

To do so, it is recommended to create a wrapper feature in order to facilitate the creation of the main jnlp file and ease the deployment. This wrapper feature will list all the plug-ins of your application. Dopo aver aggiornato la funzione, copiare il file JNLP generato e modificarlo per farlo diventare il file JNLP principale.

Miscellaneous

Java Web Start on linux

When an eclipse application is started with Web Start on Linux the default windowing system is motif. If you want to run GTK, you need to set the property osgi.ws to "gtk" in the main jnlp file. For example you can add:

  <resources os="Linux"/>
        <property name="osgi.ws" value="gtk"/>
  </resources>

Limitazioni note