Skip to content

Instantly share code, notes, and snippets.

@duyet
Created April 11, 2015 03:20
Show Gist options
  • Save duyet/34325cf4b8789efdc3cb to your computer and use it in GitHub Desktop.
Save duyet/34325cf4b8789efdc3cb to your computer and use it in GitHub Desktop.
Exec Nodejs on Nodejs Application.
var spawn = require('child_process').spawn;
var prc = spawn('java', ['-jar', '-Xmx512M', '-Dfile.encoding=utf8', 'script/importlistings.jar']);
//noinspection JSUnresolvedFunction
prc.stdout.setEncoding('utf8');
prc.stdout.on('data', function (data) {
var str = data.toString()
var lines = str.split(/(\r?\n)/g);
console.log(lines.join(""));
});
prc.on('close', function (code) {
console.log('process exit code ' + code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment