简体   繁体   中英

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. Can someone please tell me how to execute my jar with javascript? 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.

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.


Marcus

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM