Get/set the working directory
File directory()
- Returns this process builder's working directory.
ProcessBuilder directory(File directory)
- Sets this process builder's working directory.
import java.io.File;
import java.util.Map;
public class Main{
public static void main(String args[]) {
try {
ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");
pb.directory(new File("myDir"));
Process p = pb.start();
} catch (Exception e) {
System.out.println("Error executing notepad.");
}
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
ProcessBuilder:
- ProcessBuilder class
- Create ProcessBuilder
- Get/set the working directory
- Get the environment variables
- Start a new process