Really Silently Updating a NetBeans Platform Application

The NetBeans Platform Application I am working on is required to update itself silently, before the user interface appears. Most of what we used comes from Jiri Rechtacek’s excellent post How to update NetBeans Platform Application silently?

Edit 2018/11/18: Jiri’s blog post is no longer available.

Edit: Also have a look at Geertjan’s blog entry entitled How to Push NetBeans Plugins Silently to End Users? for related information.

I ran into one interesting problem, probably due to the fact that all the update stuff happens before the GUI is ready in our particular implementation. When there are updates available for the first time, unit.getAvailableUpdates() is always empty. Only once the updates have been found while running the user interface, would the updates appear in that list on next start up. So after much debugging through the NetBeans Platform source code, I found out that the update items are read from a cache. And I had to force the providers to read from the update server to overcome that. The solution finally was as simple as just adding this:

[java]List updateUnitProviders =
UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true);
for (UpdateUnitProvider provider : updateUnitProviders) {
ProgressHandle handle = ProgressHandleFactory.createHandle(
provider.getDisplayName());
try {
// the second parameter forces update from server when true
provider.refresh(handle, true);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}[/java]

On a related topic: there is another way to update an application. Simply put the .nbms in the update/download folder as described by Geertjan in hist post update/download.

Instructional designer, educational technologist and occasional lecturer who loves travel and photography

9 thoughts on “Really Silently Updating a NetBeans Platform Application”

      • Hello.
        how do you do it before UI is ready? do you just comment out the “WindowManager.getDefault().invokeWhenUIReady(new Runnable () {….” part?

        Thanks!

        Reply
          • when you do that, you didn’t run into a problem with main window starting up with size (0,0)? I am not sure why but it’s doing that so I have to get the main window and set the min size to prevent it from shrinking to size 0,0.

          • That will happen whenever the platform is shut down before the main window has been displayed. The same happened if the user cancelled out of our login dialog, which is displayed before the main window. I have logged this bug about it: http://netbeans.org/bugzilla/show_bug.cgi?id=212389 Vote for it if you want it to have more visibility to the engineering team. 🙂

    • Sorry for the very late reply… I have unfortunately not been able to find another source for this information. 🙁

      Reply

Leave a Comment