之前使用Runtime.getRuntime().exec调用外部程序,在Tomcat下会有当前线程一直等待的现象。当时为了解决这个问题,使用新建线程接收外部程序的输出信息,详情请看博客http://blog.youkuaiyun.com/accountwcx/article/details/46785437。
后来在网上找到开源的Java调用外部程序类库Apache Commons Exce,这个类库提供非阻塞方法调用外部程序。
官方网址 http://commons.apache.org/proper/commons-exec/
maven地址 http://mvnrepository.com/artifact/org.apache.commons/commons-exec/1.3
官方教程 http://commons.apache.org/proper/commons-exec/tutorial.html 官方教程提供