So i currently have a Nodejs application that spawns a child process that executes a java application and this is working just fine when ran directly from the command prompt.
http.createServer(function (request, response) {
console.log('Started Executing Request! \n' );
const { exec } = require('child_process');
exec('"C:\\Program Files\\Java\\jdk1.8.0_172\\bin\\java.exe" -jar "C:\\Temp\\myjava.jar"', (err, stdout, stderr) => {
if (err) {
console.log('There was an error! ' + err);
// node couldn't execute the command
return;
}
// the *entire* stdout and stderr (buffered)
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
});
console.log('Finished Executing Request! \n' );
}).listen(8087);
// Console will print the message
console.log('Server running at http://127.0.0.1:8087/ \n');
The problem i have is when put this into a service it doesn't seem to want to execute the java application. I have it outputing to a log file and i do have the "Started Executing Request" and the "Finished Executing Request!" within the log but the java is not executed.
I was trying to print to a label printer so what this turned out to be a problem with the printer driver itself. Seems printing from a service is prone to issues so i went a different route. What i ended doing was i created a self hosted desktop application that minimized to the system tray on windows. The above application worked properly within mac and linux.