[英]How can i run a jar file in javascript?
Sorry i am new to this and don't have much experience.对不起,我是新手,没有太多经验。 I have the jar file that takes one parameter and returns me a json with the result.我有 jar 文件,它接受一个参数并返回 json 和结果。 Can someone please tell me how to execute my jar with javascript?有人可以告诉我如何用 javascript 执行我的 jar 吗? I have tried this but doesn't work.我已经尝试过了,但没有用。
var exec = require('child_process').exec, child;
child = exec('java -jar C:\\..\\..\\myjar.jar',
function (error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if(error !== null){
console.log('exec error: ' + error);
}
});
Personally, I have no idea how to do this nor did I know executing jar files was a thing.就个人而言,我不知道如何做到这一点,也不知道执行 jar 文件是一回事。
However, I looked it up because I was curious and I found this .但是,我查了一下,因为我很好奇,我发现了这个。 Another user asked this question and the answer depended on the situations.另一个用户问了这个问题,答案取决于情况。
I hope I was helpful and I didn't just state what you already researched.我希望我对您有所帮助,而且我不只是 state 您已经研究过的内容。
Marcus马库斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.