Java ProcessBuilder Example

In this Java ProcessBuilder Example, We are showing how to run external programs and operating system commands with the help of ProcessBuilder.

We can use this java API if your JDK is above 1.5.

Each process builder manages these process attributes:

  • command, It is a list of string, each string should be a valid operating system command (see the below example)
  • environment, This will returns a copy of the environment of the current process, we are invoked.
  • working directory, It's current working directory of the process.
  • Input/Output, redirectinput/redirectOutput is for redirecting output to other resources (see the below example)

Reference-> http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html