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

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在开发 Java 桌面应用程序时,可以使用 SwingJavaFXSwing 是一个用于创建桌面应用程序的图形用户界面 (GUI) 工具包,是 Java 的标准 GUI 工具包。它提供了丰富的界面组件和布局管理器,可以让你创建复杂的界面。SwingJava 1.2 版本推出,现在已经是一个成熟的工具包。 JavaFX 是 Oracle 公司推出的一个新的 GUI 工具包,它提供了比 Swing 更多的界面组件和布局管理器,并且使用起来更简单。JavaFXJava 1.8 版本推出,是一个较新的工具包。 对于新项目,建议使用 JavaFX,因为它是 Java 的最新 GUI 工具包,提供了更多的功能和更好的用户体验。但是,如果你已经熟悉 Swing 并且项目对兼容性要求较高,也可以使用 Swing。 ### 回答2: Java开发桌面应用程序可以选择使用SwingJavaFXSwingJava提供的原生UI工具包,已经存在了很长时间,并且被广泛使用。它提供了丰富的UI组件,可以满足大多数桌面应用程序的需求。Swing使用起来相对简单,文档和教程也很丰富,对于有Java编程经验的开发人员来说,上手容易。另外,Swing在各个平台上的兼容性也相对较好,可以在Windows、Linux和Mac OS等操作系统上运行。 然而,相比于SwingJavaFX是一个更加现代化和强大的桌面应用程序开发框架。它提供了更多的UI组件和动画效果,可以构建出更漂亮和交互性更强的用户界面。JavaFX还含有更高级的功能,如支持3D图形、媒体播放和Web视图等,可以为应用程序提供更多样的功能。此外,JavaFX也更加注重可扩展性和可重用性的设计,使得开发者可以更容易地构建复杂的应用程序。 因此,选择使用Swing还是JavaFX,取决于具体的开发需求和个人技术背景。如果主要追求简单、快速的开发,并且项目不需要太多高级功能,可以选择Swing。如果对于用户体验和视觉效果有更高的要求,也希望能够方便地集成现代化的功能,可以选择JavaFX。 最后,JavaFX也在逐渐取代Swing成为Java桌面应用程序开发的主流选择,未来可能更受推荐和支持。因此,对于新项目的开发,也可以考虑选择JavaFX以避免技术落后的问题。 ### 回答3: 要选择使用Java开发桌面应用程序,可以选择使用SwingJavaFXSwingJava最早提供的GUI工具包,它简单易学,适合初学者和小型项目。Swing提供了丰富的组件和布局管理器,可以轻松构建传统的桌面应用程序界面。它的跨平台性好,可以在各种操作系统上运行,但其界面设计相对较为简单,视觉效果不够美观。 与Swing相比,JavaFX是一种更现代化、更强大的GUI工具包。它提供了更丰富的视觉效果和动画效果,支持更灵活的布局和样式。JavaFX还提供了许多更高级的功能,如多媒体支持、网络通信和3D图形支持等。JavaFX也是跨平台的,可以在各种操作系统上运行。 因此,在选择SwingJavaFX时,需要考虑项目的规模和需求。如果是一个简单的桌面应用程序,并且对界面设计的要求不高,可以选择Swing。但如果需要更好的视觉效果和更多的功能,可以选择JavaFX。另外,如果已经很熟悉Swing,也可以选择继续使用它,因为它仍然是一个可靠和强大的GUI工具包。 总之,选择使用Swing还是JavaFX取决于项目的要求和开发者的经验,需要综合考虑功能、界面设计、跨平台性和开发成本等因素。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值