How to write a self-updating program in Java? [clo

2019-01-18 06:21发布

How can i make a Java program which can update itself. I make this program for use within small team. I do not need any advanced features. I just need a simple and minimal solution.

2条回答
霸刀☆藐视天下
2楼-- · 2019-01-18 06:53

Java Web Start is meant specifically for this. You ship one jnlp file, and java takes care of fetching the newest version from a server.

Apart from that, you can download updated classes and replace them at runtime.

查看更多
神经病院院长
3楼-- · 2019-01-18 07:04

What do you mean by self-updating ?

If you mean that it changes its behavior at runtime (which is rare), you could create code that writes java code, compiles it, and loads it from within a running program. I've seen that done.

The more common scenario is to have a core program with plug-ins, where the plug-ins themselves can be updated at runtime. The simplest way to do this is simply to use interfaces for these services and then load instantiations of these types at runtime. However, writing a fully robust plug-in framework is usually reinventing the wheel. There are many existing architectures such as OSGi.

查看更多
登录 后发表回答