ProcessBuilder redirecting output
问题 I am trying to redirect output of a process started with the help of ProcessBuilder using following code ProcessBuilder pb = new ProcessBuilder("/myScript >> /myLogFile 2>&1 <& - &"); Map<String, String> env = pb.environment(); env.clear(); env.put("var1", "val1"); env.put("var2", "val2"); pb.redirectErrorStream(true); Process p = pb.start(); But it failed with exception Exception in thread "main" java.io.IOException: Cannot run program "/myScript >> /myLogFile 2>&1 <& - &": java.io