日期:2014-05-20  浏览次数:20807 次

java调用exe程序
使用Runtime.getRuntime().exec()可以调用exe
通过Runtime.getRuntime().addShutdownHook()也可以在jvm正常退出的时候结束对exe的调用。
那jvm异常退出的时候该怎么结束exe进程呢?

------解决方案--------------------
异常退出 不行吧 jvm都没机会处理就被终止了
------解决方案--------------------
结束不了的。
------解决方案--------------------
Process p = Runtime.getRuntime().exec(...);
p.destroy();
------解决方案--------------------
Uncaught exceptions are handled in shutdown hooks just as in any other thread, by invoking the uncaughtException method of the thread's ThreadGroup object. The default implementation of this method prints the exception's stack trace to System.err and terminates the thread; it does not cause the virtual machine to exit or halt. 


未捕获异常都会在shutdown hooks中处理的,楼主可能遇到的且无法处理的是什么异常呢