Is it possible to force cache clearing when a java web start application is updated?
Is it possible to force cache clearing when a java web start application is updated f开发者_运维技巧rom the command line?
Personally, I'd disable the caching while developing.
Windows: - Go go ControlPanel / Java
Linux: - $JAVA_HOME/bin/jcontrol
-> Temporary Internet Files -> Settings -> Untick "Keep temporary files on my computer"
Click on "Delete files" to clear all cache while you at it.
According to the Javaws documentation, you can clear the cache with:
javaws -uninstall
or
javaws -uninstall <jnlp>
However, almost by definition, you don't need to clear the cache if the application is being updated. It just seems that sometimes Javaws doesn't update applications.
I've resorted to checking a URL where I store the 'latest version' of my app. When the app starts, I fetch the URL and compare with the running version. If they differ, I popup a "There's a new version available - update now?" message box.
If the user selects to update, I use (with appropriate exception handling not shown):
String uri = "http://www.myserver.com/path/to/myjnlp.jnlp";
String proc = "javaws";
Process javaws = new ProcessBuilder("javaws", uri).start();
System.exit(0);
So far that seems to be enough, but if necessary, I could preface the javaws with:
Process uninstall = new ProcessBuilder("javaws", "-uninstall", uri).start();
uninstall.waitFor();
The only downside of this is that, if you have Desktop links, the user will be prompted to add those again. But that's a small price to pay to have updating actually working...
Currently there is no way to clear the cache from inside the running application, or at least I was not able to find one.
精彩评论