只要按照图进行修改就可以顺利执行
package ark;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class ReadCmdLine {
public static void main(String args[]) {
Process process = null;
List
processList = new ArrayList
();
try {
process = Runtime.getRuntime().exec("which java");
BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = input.readLine()) != null) {
processList.add(line);
}
input.close();
} catch (IOException e) {
e.printStackTrace();
}
for (String line : processList) {
System.out.println(line);
}
}
}