8

I'm creating an automated web app build process with node.js on windows. I'm trying to run our code through Google closure java program. I read the documentation on child_process in the node documents. It mentions it doesnt work in windows yet. Is there a package or work around for this?

Heres the code im trying to run.

var _exec = require('child_process').exec; _exec( 'java ' + '-jar '+ COMPILER_JAR +' --js '+ srcPath +' --js_output_file '+ distPath, function(e){ echo( "google closure done...."); echo( e ); } ); 
1
  • 1
    I'm wondering if there is a node package or some other work around I'm not aware of. Node is working great overall, this jar file step is a tiny portion of the overall process, and most of the team is on OSx / Linux. Commented Jul 26, 2012 at 22:49

1 Answer 1

15

I have a web server app for controlling a queue of builds on windows XP and I used it to run batch files or executables without any additional packages.

I would check the error parameter on the callback and stderr as this may help you find the reason it does not work.

My example solution out of my server which I hope helps:

var theJobType = 'FOO'; var exec = require('child_process').exec; var child = exec('Test.exe ' + theJobType, function( error, stdout, stderr) { if ( error != null ) { console.log(stderr); // error handling & exit } // normal }); 
Sign up to request clarification or add additional context in comments.

3 Comments

thanks. The error I'm getting is : 'java' is not recognized as an internal or external command, operable program or batch file. Can node not use system environment vars?
I have just tested, put my exe in a folder in the path and it was found. But I get your exact error if I put a non-existent exe name. So seems like its an issue resolving the path/location of java.exe
Yes, that was the issue. I added the full path to java.exe and its working now. thanks. Now I need to make it work on other machine configurations. java.exe wont work on OSX or Linux.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.