How can I make my game self destruct so I can for example make an autopatcher that deletes the old jar and downloads a new one? I’ve got this so far:
public static final void destroy() {
try {
String command = "PING -n 2 LOCALHOST > NUL&&DEL /Q " + System.getProperty("user.dir") + File.separator + "Renoria.jar";
Runtime.getRuntime().exec(command);
executePatch();
} catch (IOException ex) {
showError("Patch error", "Failed to delete the old executable");
}
System.exit(0);
}
public void executePatch() {
String home = System.getProperty("user.home");
String dir = home + "/renoriaData";
File dataFile = new File(dir + "/AutoPatch.jar");
try {
Runtime.getRuntime().exec("java -jar \"" + dataFile.getAbsolutePath() + "\"");
} catch (IOException ex) {
Logger.getLogger(Console.class.getName()).log(Level.SEVERE, null, ex);
showError("Patch failed", "Failed to execute the AutoPatcher. Please redownload the client.");
}
Runtime.getRuntime().halt(0);
}
but it doesn’t work 
Help is appreciated ;D
One more problem:
When I start a new process:
public static void main(String[] a) {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
ProcessBuilder proc = new ProcessBuilder("notepad.exe");
p = proc.start();
System.exit(0);
} catch (Exception ex) {
ex.printStackTrace();
}
}
The existing java program does not terminate until notepad is closed and I even called System.exit…
