Process builder in JAVA not working in Mac OS X:
String[] command = { "mkdir", "one"};
ProcessBuilder process = new ProcessBuilder(command);
process.start();
after this "one" directory is not created in Mac 'Home' user directory.
You need to specify the working directory in your process builder. Setting it to user's home in Mac, you can use the system property user.home
:
ProcessBuilder pb = new ProcessBuilder(command);
pb.directory(new File(System.getProperty("user.home")));
pb.start();
According to the Javadoc for java.lang.ProcessBuilder
:
Each process builder manages these process attributes:
- ...
- a working directory. The default value is the current working directory of the current process, usually the directory named by the system property
user.dir
.