import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;public class Test { public static void main(String[] args) throws IOException { Process p = Runtime.getRuntime().exec("cmd /c D:\\a.bat"); InputStream fis = p.getInputStream(); final BufferedReader br2 = new BufferedReader(new InputStreamReader(p.getErrorStream())); InputStreamReader isr = new InputStreamReader(fis); final BufferedReader br = new BufferedReader(isr); Thread t1 = new Thread(){ public void run(){ String line = null; try { while ((line = br2.readLine()) != null) { System.out.println(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; Thread t2 = new Thread(){ public void run(){ String line = null; try { while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; t1.start(); t2.start(); }}这样写就没问题了,API里有写:Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.因为本地进程输入输出缓存有限,找不到TaReport会导致stderr输出,你不快点读取的话Process就挂在那了。 下面是输出 :******************************************TAReport Start, wait for a moment please!!!******************************************java.lang.NoClassDefFoundError: TaReportCaused by: java.lang.ClassNotFoundException: TaReport at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)Could not find the main class: TaReport. Program will exit.Report has been sent, please check mail box!!!Exception in thread "main"