Implementing a JavaFX application auto update feature

Claudio Mezzasalma picture Claudio Mezzasalma · Apr 8, 2015 · Viewed 8k times · Source

I'm about to write a new cross platform application, and I choosed JavaFX, mainly because of its rich UI libraries (both standard and third party) and it native data binding feature. My application will be deployed via native packaging, both because the lack of PPAPI Java plugin (Chrome will discontinue NPAPI in Chrome 42, which is in beta now) that would prevent an user with Chrome to use WebStart, and because a more "classic" user experience, so WebStart and automatic updates are off the table.

The scenario would be the following:

  1. Application starts and checks for updates
  2. If updates are found, download them and put them in a temporary folder
  3. At application shutdown, write the newly downloaded JAR files over the old ones
  4. Automatically restart the updated application

However, a few question arises in my mind (initially these two, but I could be updating this question as soon as I have more):

  • Is it safe to do so? Am I risking that somehow the JVM gets crazy if I overwrite some of the JARs already used in the application lifecycle?
  • I'm struggling to find a way to automatically restart my JavaFX application. Is it even possible?

Thanks everyone for your help.

Answer

keuleJ picture keuleJ · Apr 8, 2015

Take a look at GetDown or UpdateFX. It implements a bootstrap downloader that checks for updates, downloads them and starts your Application as soon it is updated