Your jar
object is a ChildProcess object, which has three streams: stdin
, stdout
, stderr
. They are not functions, but streams that you can read from (stdout and stderr) and write to (stdin).
Here is an example:
jar.stdin.write('stop\n');
jar.stdout.pipe(process.stdout);
which will write some data to the standard input of your child process, and pipe its output to the standard output of your Node process (ie. the console).
Note that the write()
call is asynchronous: there may be a small delay between the time you called write()
and the time it is really written to the process input.
For an overview of streams, you can read The Stream Handbook.