简体   繁体   中英

Java - How do i close myself and restart myself, such as my software kernel panic and i need reboot itself?

I have a case, where i need to do System.exit(0); and then immediately restart the same application on kernel panic or something like that. But if i call System.exit(0) first how do i call the exec() ? Like in linux i got it working with BASH.

#!/bin/bash
pkill java;
sleep 1;
java -cp /var/tmp/dist/Kernel.jar main.Kernel

Main.java:

/* Windows platform running */
public class Main {
  public static void main(String[] args) 
  {
    // other activity happening.... for ages

    // 
    // Suddently there will be a kernel panic it is better to do a software reboot 
    // remotely
    //
  }

  public static rebootSoftwareKernel()
  {
    System.exit(0); // Exit completely
    Runtime.getRuntime().exec( MyConstant.RunItSelfSoftReboot() ); // Restart this same 
  }
}

Look into Tanuki Service Wrapper . Among other features it allows to restart the JVM when needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM