0

I have a Process created with ProcessBuilder. It basically is wrapping a keytool command: https://www.tbs-certificates.co.uk/FAQ/en/627.html

after I call processBuilder.start(), normally my keytool command would ask for the password. How do I input my password after I run processBuilder.start()?

Crystal
  • 28,460
  • 62
  • 219
  • 393

1 Answers1

0

You'll want to access the process IO streams, the JavaDoc shows that the methods you want to use are:

  • getOutputStream() for the process System.in
  • getInputStream() for the process System.out
  • getErrorStream() for the process System.err

You will want to wrap the input and error streams in Scanners to read lines from them, and the output stream in a PrintStream so you can print to it in a similar way to System.out.

You can read in the request for the password, and then print the password out to the process.

jrtapsell
  • 6,719
  • 1
  • 26
  • 49