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

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.