Why does this :
Runtime rt = Runtime.getRuntime();
String cmd = "cmd /c java -version";
Process process = rt.exec(cmd);
process.waitFor();
StringBuffer output = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line;
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
System.out.println(output);
} catch (Exception e) {
logger.error(e);
}
print into the error stream and not in the standard input stream? What is erroneous about the command java -version
?
N.B. The cmd /c
is because I am on a Windows machine