I am building some kind of an updater function in my program. When an update is detected, the program should download an updater.jar
and terminate. After that, the updater.jar
will download a new version of the program and delete the old one. This is how my main program runs the updater:
Runtime.getRuntime().exec("java.exe -jar updater.jar "+updateURL+" "+workingPath);
System.exit(0);
However, for some reason, the System.exit(0)
doesn't get called until the updater is done... and the updater can't remove the old version of the main program while it's running. Result: everything starts hanging.
Anyone got an idea how to tell my main program /not/ to wait for the updater to terminate before calling System.exit(0)
?
EDIT:
FileUtils.copyURLToFile(url, file);
System.out.println("Downloading updater...");
new Thread() {
public void run() {
try {
Runtime.getRuntime().exec("java.exe -jar updater.jar "+updateURL+" "+workingPath);
} catch (IOException ex) {
System.out.println("Exception: " + ex.getMessage());
}
}
}.start();
System.out.println("Shutting down application.");
System.exit(0);
Cmd displays the "Shutting down application."
, but the jar
doesn't seem to be shutting down until I manually kill the process.