从服务器更新应用程序的最佳方法是什么?

发布于 2024-10-29 18:02:39 字数 164 浏览 4 评论 0原文

我正在寻找非 webstart/jnlp 解决方案。

我想向我的应用程序添加一项更新功能,该功能可检查 ftp 或 http 服务器并下载最新版本(如果有更新的版本)以替换已更改的库。

我怎样才能做到这一点?我想实现 JDownloaders 更新之类的东西。

谢谢

I'm looking for a non-webstart/jnlp solution.

I'd like to add to my app an update feature that checks in an ftp or http server and downloads the last version (if there is a newer one) replacing the libs that has been changed.

How can i do that? I want to implement something like JDownloaders updates.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

彩扇题诗 2024-11-05 18:02:39

看来您刚刚准确描述了如何做到这一点。添加更新功能,检查 FTP 或 HTTP 服务器并下载最新版本。

请记住,您无法下载并覆盖正在使用的文件。因此,从我的角度来看,您有两种设计选择:

  1. 当您启动应用程序时,将所有 jar 和库文件复制到某种 /temp 文件夹中,然后再运行它们。然后,当您下载更新时,覆盖原来位置的文件。下次应用程序启动时,它将使用新文件。

  2. 启动应用程序时,首先启动更新程序。让它连接到服务器并比较所有文件版本。它将能够覆盖任何应用程序文件,因为它不使用它们。它仅使用更新程序 jar。完成此操作并更新所有内容后,然后从更新程序使用实际应用程序启动新流程。您还需要放入一些代码才能更新更新程序 jar。要么使主应用程序能够更新更新程序,要么使用第一种技术并从更新程序 jar 的副本运行更新程序。

请记住,当您下载文件时,应该将它们下载到临时位置,然后在完成后将它们移动到正确的位置。这将确保您的应用程序永远不会处于“半下载”状态。

除此之外,要让它发挥作用还需要进行大量的测试。祝你好运!

It looks like you just described exactly how to do it. Add an update feature that checks an FTP or HTTP server and downloads the latest version.

Remember that you cannot download and overwrite a file which is in use. So you have two options for a design from where I sit:

  1. When you start up the application, copy all of the jar and library files to a /temp folder of some sort before running them. Then, when you download the update, overwrite the files in the original place. The next time the application starts up, it will use the new files.

  2. When you start up the application, first startup an updater. Have it connect to the server and compare all of the file versions. It will be able to overwrite any of the application files because it doesn't use them. It only uses the updater jar. Once this is done and everything has been updated, then start a new process from the updater with the actual application. You will also need to put some code in to be able to update the updater jar. Either make the main application be able to update the updater, or use the first technique and run the updater from a copy of the updater jar.

Remember when you download the files that you should be downloading them to a temporary location and then moving them to the right place when they're done. This will make sure that you never leave your application in a "half-downloaded" state.

Beyond that, getting this to work is going to be about a lot of testing. Good luck!

瑕疵 2024-11-05 18:02:39

看看 http://code.google.com/p/getdown/

根据对于stackoverflow上的this问题,它似乎是网络启动的一个可行替代方案(至少值得拥有一看)。

Have a look at http://code.google.com/p/getdown/

According to this question on stackoverflow it seem to be a viable alternative for web start (at least worth having a look at).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文