{"id":496,"date":"2012-08-21T15:14:50","date_gmt":"2012-08-21T13:14:50","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=496"},"modified":"2018-11-18T18:08:01","modified_gmt":"2018-11-18T16:08:01","slug":"really-silently-updating-a-netbeans-platform-application","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=496","title":{"rendered":"Really Silently Updating a NetBeans Platform Application"},"content":{"rendered":"<p>The NetBeans Platform Application I am working on is required to update itself silently, <em>before<\/em> the user interface appears. Most of what we used comes from Jiri Rechtacek&#8217;s excellent post <em>How to update NetBeans Platform Application silently?<\/em><\/p>\n<p><strong>Edit 2018\/11\/18:<\/strong> Jiri&#8217;s blog post is no longer available.<\/p>\n<p><strong>Edit:<\/strong> Also have a look at Geertjan&#8217;s blog entry entitled <a href=\"https:\/\/blogs.oracle.com\/geertjan\/entry\/how_to_push_netbeans_plugins\">How to Push NetBeans Plugins Silently to End Users?<\/a> for related information.<\/p>\n<p>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:<\/p>\n<p>[java]List updateUnitProviders =<br \/>\n        UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true);<br \/>\nfor (UpdateUnitProvider provider : updateUnitProviders) {<br \/>\n    ProgressHandle handle = ProgressHandleFactory.createHandle(<br \/>\n            provider.getDisplayName());<br \/>\n    try {<br \/>\n        \/\/ the second parameter forces update from server when true<br \/>\n        provider.refresh(handle, true);<br \/>\n    } catch (IOException ex) {<br \/>\n        Exceptions.printStackTrace(ex);<br \/>\n    }<br \/>\n}[\/java]<\/p>\n<p>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 <a href=\"https:\/\/blogs.oracle.com\/geertjan\/entry\/update_download\">update\/download<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;s excellent post How to update NetBeans Platform Application silently? Edit 2018\/11\/18: Jiri&#8217;s blog post is no longer available. Edit: Also have a look at Geertjan&#8217;s blog entry &#8230; <a title=\"Really Silently Updating a NetBeans Platform Application\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=496\" aria-label=\"More on Really Silently Updating a NetBeans Platform Application\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[3,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-80","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/496"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=496"}],"version-history":[{"count":2,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/496\/revisions"}],"predecessor-version":[{"id":1094,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/496\/revisions\/1094"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}