Java Web Start: как заставить систему загружать файл каждый раз, когда файл изменяется - PullRequest
1 голос
/ 21 июля 2011

Я только что реализовал приложение 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.

Означает ли это, что ситуация, при которой последняя версия не будет запускаться, будет происходить довольно часто на практике, если сеть работает медленно? Т.е. как быстро "достаточно быстро"?

Спасибо за все вклады!

1 Ответ

6 голосов
/ 21 июля 2011

Вы должны использовать элемент обновления:

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

Я не знаю, под какой версией java вы запускаете ваше приложение, но элемент обновления был введен в java6:

Элемент ОБНОВЛЕНИЯ

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.
...