0

Well here is the shutdown method

public static void restart() {
    closeServices();
    System.gc();
    try {
        Runtime.getRuntime().exec("run.cmd");
        System.exit(0);
    } catch (Throwable e) {
        Logger.handle(e);
    }

}

And here is the run.cmd

java -javaagent:"C:\Program Files (x86)\ZeroTurnAround\JRebel\jrebel.jar" -cp bin;data/FileStore.jar;data/netty-3.5.2.Final.jar;xstream-1.4.3.jar;data/mysql.jar com.rs.Launcher

How do I make it show that it runs run.cmd and closes the last one? Right now all it does is just exit the current server and doesn't startup a new one.

hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
Jonathan Beaudoin
  • 2,158
  • 4
  • 27
  • 63
  • 2
    I'm not certain, but most likely, killing the VM will also kill all child processes. – Jochen Aug 20 '12 at 22:33
  • Does your `closeServices();` ensure that the previous instance has shutdown before you start creating a new one? and +1 with @Jochen – Sujay Aug 20 '12 at 22:35
  • Your native exec handling might not know to execute .cmd files with CMD. – FThompson Aug 20 '12 at 22:37

1 Answers1

1

Make another batch script with

taskkill /F /IM java.exe

And this will surely do.

Programmatically:-

public static void restart() {
    closeServices();
    System.gc();
    try {
        Runtime.getRuntime().exec("taskkill /F /IM java.exe");
        System.exit(0);
    } catch (Throwable e) {
        Logger.handle(e);
    }    
} 
perilbrain
  • 7,961
  • 2
  • 27
  • 35