$PATH 变量不是通过 getRuntime().exec 继承的 [英] $PATH variable isn't inherited through getRuntime().exec
本文介绍了$PATH 变量不是通过 getRuntime().exec 继承的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过以下 Java 命令启动脚本:
I'm trying to start a script by the following command in Java:
proc = Runtime.getRuntime().exec(cmd, null, fwrkDir);
在控制台中输入的命令完美无缺.但是在这里它似乎没有找到脚本,即使它的路径被添加到 $PATH 变量中.如果 null 作为 Environment 传递,Java 不会自动继承所有这些变量吗?
The command, typed in a console, works flawlessly. But here it doesn't seem to find the script, even though it's path is added to the $PATH variable. Doesn't Java automatically inherit all such variables, if null is passed as Environment?
推荐答案
proc = Runtime.getRuntime().exec(cmd, null, fwrkDir);
应该是
proc = Runtime.getRuntime().exec(cmd, "PATH=$PATH:/android-sdk-linux_x86/platform-tools", fwrkDir);
这篇关于$PATH 变量不是通过 getRuntime().exec 继承的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文