我需要读取在 IBM j9(模拟器 JVM 到 windows mobile)上运行的进程的输出。我试过这个:
Process p = Runtime.getRuntime().exec("j9.exe");
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String stringLog;
while ((stringLog = br.readLine()) != null) {
System.out.println(stringLog + "\n");
}
但它不起作用,因为它返回了 的新实例j9.exe
,而不是现有进程。
我需要从 j9console (现有进程的)获取所有记录到 System.out 的消息。我该怎么做呢?