Search code examples
javadeploymentjarjava-web-start

How to deploy jar both with Web Start and an installer?


I have a Java desktop application and now we distribute it as a jar in a installer of a main application (currently the Java application is only an importer/exporter). But as the jar is updated more often than the main application we are thinking of making it run through Java Web Start so it's updated independently when it start.

My question is how can I distribute it in the installer so if the user don't have internet it use the jar bundle in the installer (and copied in the main application folder) but when he launch and have internet, Java Web Start update it?

Edit: I have think in making two JNLP files one for local launch and one for online launch so it get updated, but then they need to share the cached jar so isn't installed two times, and I don't know if this is possible.

Edit, more explanations:

Maybe I haven't explain it very well. I have a native application and is distributed as an MSI, from download and through CD. With this application we distribute the Java application (a jar) that the main application used to exchange data to other formats. The MSI installs both the native app and copy the jar (not really install). Now if the user have internet and a new update is published, the complete MSI is downloaded and installed (updating the installation). Ok?

Well, we like to update only the jar in a more fashion approach, with Java Web Start, so it's updated when the jar is run independently of the main app. This have the problem that if we only deploy it as Java Web Start, if the user install the app in a computer without internet (for example carrying the MSI in a pen-drive or cd) he will not be able to use it, because as he don't have internet he can't download the jar.

And now is when my question come, can I deploy the jar in the MSI but execute through a Java Web Start so if the user have internet it get updated but if he doesn't have internet it still can use the bundle jar in the MSI?


Solution

  • ..can I deploy the jar in the MSI but execute through a Java Web Start so if the user have internet it get updated but if he doesn't have internet it still can use the bundle jar in the MSI?

    OK, I am formulating a plan here, this might be doable.

    Let us presume that the MSI is capable of doing the following things.

    • Install a JRE if missing or too low a version available. The JRE needs to be included in the MSI (to avoid requiring the net).
    • Unpack the JWS launch file and Jar(s) (and native..) to the local file system as temporary files.
    • Invoke the javaws tool using 'IMPORT-OPTIONS' to set the code-base to the place in the local file-system they were unpacked.

    At this point, desktop icons and shortcuts should be installed, and the program ready to launch. It is vital to specify a few extra options in the JNLP - specifically offline-allowed to ensure the app. can still be launched if the internet is not available.

    Caveats: I don't have any experience with MSI, and my experience with using the import options is limited to calling them from build files (during development).