java swing 升级,Java Swing桌面应用程序中的自动更新功能

作者探讨了在开发Swing桌面应用时如何实现自动更新功能,考虑了Java Web Start的局限性,提出了一种方案:使用一个启动JAR检查配置版本并下载新版本资源,包括jar、配置文件和图标。这种方法涉及新jar替换旧版本,同时关注安全性问题和启动新jar的复杂性。
摘要由CSDN通过智能技术生成

I've developed a desktop Swing app and I'm thinking about the best way to provide the autoupdate feature.

I know that JavaWebStart provides this but I think that It doesn't suit my needs because I need to read local files so I would need to sign the jar. Besides, JWS requires extra work to deploy in the server while now I only need to upload the .jar.

I've been thinking about this approach:

A first JAR (which never needs updating) loads the splashscreen, checks the current version in a config.xml and compares it to the server config.xml.

If server version is newer, ask the user whether he wants to update. In that case, download the new "main.jar", the new "config.xml" and the new splash/icon, check MD5SUM, and replace the old files with the new ones.

Launch "main.jar".

I don't know If I'm trying to reinvent the wheel or If there's a better pattern than the one I've put above.

解决方案

We did a similar thing. We just got it via https and downloaded the jar. To know if you need a new one we just check the size on the stream. Theoretically that may not work, but in practice it did. We got even fancier by getting the directory listing where the jars were located, parsing it and downloading each jar, so the name of the jar wasn't hard coded either. There are a couple of ugly points, though.

First was launching a new jvm process to start the new jar is a not so simple.

Second, you have to be sure you don't corrupt your jar if your update fails in the middle.

Finally, there is no way to update the bootstraping jar with this process.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值