Is it possible to force cache clearing when a java web start application is updated from the command line?
In the Java Control Panel's General panel, click the Settings button and the Delete Files button. Select all the check boxes that contain references to Applications and Applets. Click OK to clear the cache. When a message indicates that the JAR cache is cleared, click OK.
About this task. Launch the Java Control Panel program by running $JAVA_HOME/jre/bin/ControlPanel from a shell prompt. On the General tab, click Delete Files in the Temporary Internet Files section at the bottom of the panel. On the Delete Temporary Files window that opens, ensure that Downloaded Applets is checked.
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With