Java Web Start:如何在每次文件更改时使系统下载文件

zw3*_*324 1 java jnlp java-web-start

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

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

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

我还从官方指南中注意到这一点:

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.

这是否意味着如果网络速度慢,在实践中将不会经常运行最新版本的情况?也就是说,"合理快速"的速度有多快?

感谢所有的投入!

dav*_*orp 6

您应该使用update元素:

<jnlp>
...
<update check="always" policy="always"/>
...
</jnlp>
Run Code Online (Sandbox Code Playgroud)

我不知道你在哪个版本的java上运行你的应用程序,但更新元素是在java 6中引入的:

更新元素

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:
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)