Node.js can't get output of spawned process

This code get output of spawned process. What is wrong? node version is v0.10.22

var spawn = require('child_process').spawn;
var what = 'java';
var spawned = spawn(what,  ['-version']);

console.log('starting `'+what+' -version`');

spawned.stdout.on('data', function (data) {

spawned.on('close', function (code) {
    console.log('process exit code ' + code);

var whendone = function() {

As you can see I even added some timeout to wait for a launched process to finish.


java -version writes to stderr.

Need Your Help

Changing default encoding of Python?

python encoding utf-8 console

I have many "can't encode" and "can't decode" problems with Python when I run my applications from the console. But in the Eclipse PyDev IDE, the default character encoding is set to UTF-8, and I'm...

"rails generate controller ControllerName" not creating default 7 REST actions


If I run rails generate controller ControllerName I get an empty controller? I can manually edit it to what I want but why does this seem to happen? Is it not suppose to put the 7 default in ther...