What's the best way to add a self-update feature to a Java Swing application?

前端 未结 6 1428
你的背包
你的背包 2020-12-15 09:22

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 functio

相关标签:
6条回答
  • 2020-12-15 09:29

    Updates, plugins, separation of concern etc. are exactly what OSGi is about - you might want to take a look at this. It won't come free (read: with a steep initial learning curve, especially when you are currently using classloading tricks) at least there are good open source implementations (felix - see felix.apache.org, equinox - see www.eclipse.org and others)

    For these implementations autoupdaters are available - if you write your modules correctly it's possible to update at runtime without restarting.

    0 讨论(0)
  • 2020-12-15 09:30

    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.

    0 讨论(0)
  • 2020-12-15 09:35

    we had a swing app 6 years ago that had self-update. like you suggested,

    1)it downloaded the latest jars over http,
    2) copied them to a folder.
    3) since the swing app is launched using a .BAT file, after user said YES, we would shut down the swing app and look for any files in the update folder. if yes, launch another .BAT file to copy the NEW JARs to the required directory.
    4) then re launch the swing app.

    0 讨论(0)
  • 2020-12-15 09:39

    The Java Web Start is good choice. The GC stuff is not important. Classloading could be problem. But when you got trusted by user you can grant AllPermisions and you will be able to do custom classloading. Maybe it will be good to reconsider funky stuff with classloading. It is really necessary? Or look at NetBeans. There should be found inspiration for auto-update.

    0 讨论(0)
  • 2020-12-15 09:44

    I would definitely first try out Webstart. We've had lots of success launching even the early Eclipse RCP apps using Webstart, and you can probably not get more funky classloading issues than with the OSGI framework (Eclipse Equinox).

    Could you perhaps give some more detail in your question about you classloading approach?

    Regarding the GC and other VM settings: these are easy to specify in your JNLP (Java Network Launching Protocol) files used by Webstart for launching apps.

    0 讨论(0)
  • 2020-12-15 09:52

    I believe you should look again at Java WebStart, or at least detail the "funky classloading" which you think is going to cause problems (as it might also cause problems with any solution proposed here).

    IIRC, you can set command line parameters using Java WebStart ( http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources ).

    0 讨论(0)
提交回复
热议问题