关于Process p = Runtime.getRuntime().exec(cmdString)的问题?

lwd2k 2004-04-07 05:04:59
我在第一个class里用的cmdString是"java ****",
用命令行方式执行第二个class,
在第二个class中又用了Runtime.getRuntime().exec(cmdString),
在里面打开了WINRAR程序。
现在用debug方式执行第一个class时,只有强制关掉第一个class后,才显示RAR窗口(执行第二个class)。

/*class 1*/
Process p = Runtime.getRuntime().exec(cmdString);
p.waitFor();
int exitValue = p.exitValue();
println("exit" + exitValue);
...全文
267 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwd2k 2004-05-08
  • 打赏
  • 举报
回复
谢谢,以后试试。
panpan221 2004-04-30
  • 打赏
  • 举报
回复
新手学习
kinzey34 2004-04-30
  • 打赏
  • 举报
回复
由于第1个class 产生的外部进程无法结束,请清空标准输出流或许能解决问题:
Process p = Runtime.getRuntime().exec(cmdString);

InputStream stdOut = p.getInputStream();
InputStreamReader isr = new InputStreamReader(stdOut);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null){}

p.waitFor();
int exitValue = p.exitValue();
println("exit" + exitValue);
binny 2004-04-07
  • 打赏
  • 举报
回复
%^*%^&*%^&$#%^@#%$!@#~

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧