0

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);
}
});
  • Please explain your environment -- windows + nodejs? Any errors? That path -- did you try just running minimal helloWorld.java this way? – Simon B. Mar 15 '21 at 22:21

1 Answers1

0

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