首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

java调用exe程序解决办法

2013-04-05 
java调用exe程序使用Runtime.getRuntime().exec()可以调用exe通过Runtime.getRuntime().addShutdownHook()

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中处理的,楼主可能遇到的且无法处理的是什么异常呢

热点排行