public static void main(String[] args) {
try { Process pro = Runtime.getRuntime().exec("cmd /c java -version"); pro.waitFor(); BufferedInputStream br = new BufferedInputStream(pro.getInputStream()); BufferedInputStream br2 = new BufferedInputStream(pro.getErrorStream()); int ch; System.out.println("Input Stream:"); while((ch = br.read())!= -1){ System.out.print((char)ch); } System.out.println("Error Stream:"); while((ch = br2.read())!= -1){ System.out.print((char)ch); } } catch (IOException e) { e.printStackTrace(); }catch (InterruptedException e2) { e2.printStackTrace(); } }