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 bet开发者_开发百科ter 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!
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.
精彩评论