Java – What’s the best way to add a self-update feature to a Java Swing application


I'm trying to figure out a way to add a self-update feature to a Java/Swing application I'm working on.

Basically I've got a bunch of jar files with extra functionality to be re-deployed to the installed users when they change. Nothing complicated, just check if a new version has been released, download them over HTTP, and then optionally offer to restart the app to the user.

I had a look at webstart, and it could work. But this particular app does some funky stuff with classloading and GC memory settings that don't look like they are supported via webstart, or will at least complicate matters. (It's a tweaked build of JMeter)

I also went down the road of adding in this plugin handler, but it is very alpha, and tries to do too much with the usual bugs you get with alpha stuff.

Best Solution

I did the exact same thing. But that was long back so there are probably better tools today.

What I found out I needed was a loader. The loader main program did not have the app jars in classpath. It first downloaded an update if required and then created a custom classloader with the app jars in class path and invoked the main method of the application main class. It is not very complicated. IIRC I needed to do this because the jars could not be overwritten in windows if they were already in classpath.

Hope this helps.