title: opening a shell and interact with using Java
body: <p>I had previously asked the same question but with no answer, and have found some other questions similar to this problem <a href="https://stackoverflow.com/questions/20188362/using-xterm-with-java">here</a> and <a href="https://stackoverflow.com/questions/13431473/opening-a-shell-and-interacting-with-its-i-o-in-java">here</a> but again with no appropriate answers.
  Can anyone please help me out with this. I am trying to open a shell from Java and interact with it (write commands and read the shell's output). The commands will be given by the user like changing directory, compiling a C program etc. The command list is not fixed.</p>
  
  <p>I have also tried and use the /bin/bash -c  method and the following as well.</p>
  
  <pre><code>Process p = new ProcessBuilder("xterm").start();
  
  Process p = new ProcessBuilder("/bin/bash").start();
  </code></pre>
  
  <p>Thanks and I hope that the problem is clear.</p>