所以我目前有一个 Nodejs 应用程序,它产生一个执行 java 应用程序的子进程,当直接从命令提示符运行时,它工作得很好。
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');
我遇到的问题是,当将其放入服务时,它似乎不想执行 Java 应用程序。我有它输出到一个日志文件,我有“开始执行请求”和“完成执行请求!” 在日志中,但未执行 java。
我试图打印到标签打印机,结果这是打印机驱动程序本身的问题。似乎从服务打印很容易出现问题,所以我走了一条不同的路。我最后做的是创建了一个自托管的桌面应用程序,该应用程序最小化到 Windows 上的系统托盘。上述应用程序在 mac 和 linux 中正常工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句