Runtime.exec 失败,没有任何异常/警告/错误代码
这真的很奇怪,正在侵蚀我的大脑。我正在使用 Runtime.exec 启动另一个 jvm,即使没有启动它也会悄悄退出。
p = Runtime.getRuntime().exec("java classname", null, new File(workdir));
该进程立即退出。我在任务管理器中简单地看到了该进程,然后它就消失了。我什至尝试捕获输出。
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String errString = "Error Details:\n";
String line;
while((line = br.readLine()) != null)
errString = errString.concat(line).concat("\n");
第一次 readline 调用时该行为空。我知道我可以使用 ProcessBuilder,但我使用的是 java 1.4,我不能使用 1.5。请帮忙。
谢谢,比卡什
This is really weird and eating away my brains. I am using Runtime.exec to start another jvm and it quietly exits even without starting.
p = Runtime.getRuntime().exec("java classname", null, new File(workdir));
The process exits immediately. I briefly see the process in taskmanager and it goes off. I even tried to capture the output.
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String errString = "Error Details:\n";
String line;
while((line = br.readLine()) != null)
errString = errString.concat(line).concat("\n");
The line is null at the first readline call. I know i could use ProcessBuilder but i am on java 1.4 and i cannot go for 1.5. Please help.
Thanks, Bikash
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将命令放入命令行数组中:
Try putting the commands in a command line array:
当人们Runtime.exec() 出现问题
I always point to this site when people are having problems with Runtime.exec()