ProcessBuilder与Runtime.exec()的区别我试图从java代码中执行一个外部命令,但我注意到Runtime.getRuntime().exec(...)和new Process(...).start().使用时Runtime:Process p = Runtime.getRuntime().exec(installation_path +
uninstall_path +
uninstall_command +
uninstall_arguments);p.waitFor();exitValue为0,命令终止为ok。然而,与ProcessBuilder:Process p = (new ProcessBuilder(installation_path +
uninstall_path +
uninstall_command,
uninstall_arguments)).start();p.waitFor();退出值为1001,命令在中间终止,尽管waitFor退货。我该怎么做才能解决这个问题?ProcessBuilder?
3 回答
元芳怎么了
TA贡献1798条经验 获得超7个赞
Runtime.getRuntime().exec()
ProcessBuilder
exec(String[] cmdarray, ......)
ProcessBuilder
.
ProcessBuilder
ProcessBuilder
String...
shell$ "command with args"
- 3 回答
- 0 关注
- 474 浏览
添加回答
举报
0/150
提交
取消