Java write to Stdin <p>So I have imported a jruby interpreter as a library to run an external ruby application. However I need to interact with the ruby application in some way. Right now I have the ruby application outputting information on stdout and requesting user options in stdin.</p> <p>So if I want java to be able to handle inserting the options instead of a user, I'll need a way that I can write to the stdin somehow from java to choose the options. Does anyone know how I can do this? Or even a better way to do this?</p> <p>I'm calling jruby like so:</p> <pre><code>String[] newargs = new String[2]; newargs[0] = "-S"; newargs[1] = "path_to_some_rubyfile.rb" org.jruby.Main jruby = new org.jruby.Main(); ruby.main(newargs); </code></pre> <p>The ruby app outputs stuff like this:</p> <pre><code>How do you feel today? (1) Happy (2) Sad </code></pre> <p>And then waits for the user input to enter 1 or 2. But I would like Java to input these options instead of having a user do it.</p>