Java Web Start:如何让系统每次文件更改时都下载该文件

发布于 2024-11-25 10:59:39 字数 585 浏览 0 评论 0原文

我刚刚实现了一个Java Web Start应用程序,在编程过程中我注意到一个问题:

如果我分发一个版本并使用JNLP文件下载它,我无法让系统再次下载文件,除非我添加/删除文件或从 Java 缓存中清除任务。这意味着如果我只是修改文件,系统将不会下载新文件:它只会使用旧文件。

我知道我可能可以禁止系统缓存文件,但是有没有更好的方法来更优雅地解决这个问题?

我还从 官方指南< /a>:

如果指定了允许脱机,Java Web Start 还将检查是否有可用更新。但是,如果应用程序已下载,则检查将在几秒钟后超时,在这种情况下,将启动缓存的应用程序。如果服务器连接速度合理,通常会运行应用程序的最新版本,但这并不能保证。不过,该应用程序可以离线运行。

这是否意味着,在实际应用中,如果网络速度较慢,最新版本无法运行的情况会经常发生?即,“相当快”有多快?

感谢您的所有投入!

I've just implemented a Java Web Start application, and I noticed one problem during the programming process:

If I distribute a version and use the JNLP file to download it, I cannot let the system to download the files again unless I add/delete files or clear the task from the Java cache. That means if I just modify the files the system will not download the new file: it will just use the old ones.

I know I probably can just forbid the system to cache the files, but is there a better way to solve this more elegantly?

Also I note this from the Official Guide:

If offline-allowed is specified, Java Web Start will also check to see if an update is available. However, if the application is already downloaded the check will timeout after a few seconds, in which case the cached application will be launched instead. Given a reasonable fast server connection, the lastest version of the application will usually be run, but it is not guaranteed. The application, however, can be run offline.

Does that means the situation in which the latest version will not be run will occur quite frequently in practice if the web is slow? I.e., how fast is "reasonably fast"?

Thanks for all the inputs!

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

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

发布评论

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

评论(1

比忠 2024-12-02 10:59:39

您应该使用 update 元素:

<jnlp>
...
<update check="always" policy="always"/>
...
</jnlp>

我不知道您在哪个版本的 java 下运行应用程序,但是 update 元素 是在 java 6 中引入的:

UPDATE 元素

The update element is used to indicate the preferences for how application updates should be handled by Java Web Start.
The update element can contain the following two optional attributes:

check attribute: The check attribute indicates the preference for when the JNLP Client should check for updates, and can have one of the three values: "always", "timeout", and "background"

A value of "always" means to always check for updates before launching the application.

A value of "timeout" (default) means to check for updates until timeout before launching the application. If the update check is not completed before the timeout, the application is launched, and the update check will continue in the background.

A value of "background" means to launch the application while checking for updates in the background.

policy attribute: The policy attribute indicates the preference for how the JNLP Client should handle an application update when it is known an update is available before the application is launched, and can have one of the following three values: "always", "prompt-update", and "prompt-run"

A value of "always" (default) means to always download updates without any prompt.

You should use the update element:

<jnlp>
...
<update check="always" policy="always"/>
...
</jnlp>

I don't know under which version of java you're running your app, but the update element was introduced in java 6:

UPDATE Element

The update element is used to indicate the preferences for how application updates should be handled by Java Web Start.
The update element can contain the following two optional attributes:

check attribute: The check attribute indicates the preference for when the JNLP Client should check for updates, and can have one of the three values: "always", "timeout", and "background"

A value of "always" means to always check for updates before launching the application.

A value of "timeout" (default) means to check for updates until timeout before launching the application. If the update check is not completed before the timeout, the application is launched, and the update check will continue in the background.

A value of "background" means to launch the application while checking for updates in the background.

policy attribute: The policy attribute indicates the preference for how the JNLP Client should handle an application update when it is known an update is available before the application is launched, and can have one of the following three values: "always", "prompt-update", and "prompt-run"

A value of "always" (default) means to always download updates without any prompt.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文