在新过程中使用路径。它不用于查找命令。
您可以尝试下一个解决方案。运行cmd.exe(bash等),然后运行命令。
例:
public class Test { public static void main(String[] args) throws IOException { ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/C", "start", "mystuff.exe"); Map<String, String> envs = pb.environment(); System.out.println(envs.get("Path")); envs.put("Path", "C:\mystuff"); pb.redirectErrorStream(); pb.start(); }}


