title: run interactive command line application from java
body: <p>I normally use java.lang.ProcessBuilder and java.lang.Process to run external command line programs, and it works fine for run-and-done commands. For example, this would run "myProgram" with argument "myArg" in the working directory:</p>
  
  <pre><code>List&lt;String&gt; commandLine = new ArrayList&lt;String&gt;();
  commandLine.add("myProgram");
  commandLine.add("myArg");
  ProcessBuilder builder = new ProcessBuilder(commandLine);
  builder.redirectErrorStream(true);
  Process process = builder.start();
  </code></pre>
  
  <p>However, say I wanted to run a script or program or something that had interactive input (it prompted me for more input after starting). Can I do that in Java with code similar to that above, or do I need a different approach? Or is there some library that can help me with this?</p>