Run executable from Java

If a script needs to be executed, the shell needs to be executed with the script as an argument. On windows, this shell should be cmd.exe. On linux, this shell may be bash or other shell.

 

ProcessBuilder give more control over the executable than Runtime. For example, the former can redirect stderr to stdout and configure environment variable for the new process.

 

For System.getenv, cygwin is a special case. It recognized environment variable configured in ~/.bashrc if bash shell is used.

你可能感兴趣的:(java,linux,windows,bash)