我有一个案例,需要执行System.exit(0);
操作,然后在内核死机或类似情况下立即重新启动同一个应用程序。但是,如果我首先调用system.exit(0),如何调用exec()?就像在linux中,我用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
}
}
最佳答案
查看Tanuki Service Wrapper。在其他特性中,它允许在需要时重新启动jvm。
关于java - Java-如何关闭自己并重新启动自己,例如我的软件内核崩溃,我需要重新启动自己?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9558875/