具有不同PATH的ProcessBuilder对象

时间:2018-11-14 13:37:41

标签: java process processbuilder

你好,我在Linux centos 7上运行了两次Java代码,代码是:

        ProcessBuilder pb = new ProcessBuilder(commandArr);
        pb.redirectErrorStream(true);
        Map<String, String> envs = pb.environment();

        logger.info("In the process builder , the PATH is - " + envs.get("PATH"));
        Process p = pb.start();

路径是

PATH=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin   

那么下一次是

PATH=/usr/local/bin:/usr/bin   

这种变化的来源是什么?

0 个答案:

没有答案