How to set working directory with ProcessBuilder How to set working directory with ProcessBuilder unix unix

How to set working directory with ProcessBuilder


You are trying to execute /home and it is not an executable file. The constructor argument of the process builder is the command to execute.

You want to set the working directory. You can that it via the directory method.

Here is a complete example:

Process p = null;ProcessBuilder pb = new ProcessBuilder("do_foo.sh");pb.directory(new File("/home"));p = pb.start();