我有一个案例,我需要执行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服务包装。在其他功能中,它允许在需要时重新启动JVM。