简体   繁体   English

如何在 javascript 中运行 jar 文件?

[英]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.

相关问题 如何在 bash 中运行 JavaScript 文件 - How can I run a JavaScript file in bash 如何在 javascript 中运行 jar 文件并让它返回 json - How to run a jar file in javascript and have it return a json 如何像批处理文件一样运行 javascript? - How can I run javascript like a batch file? 如何使用javascript命令运行node.js文件? - How can I run a node.js file with a javascript command? 如何使用 Mongo Shell 运行裸 JavaScript 文件? - How can I run a bare JavaScript file with Mongo Shell? 我可以通过javaScript运行可执行文件吗? - Can I run an executable file through javaScript? Javascript,如何在Mirth中运行.exe文件? 如何在Mirth中调用ActiveXObject? - Javascript , how can I run .exe file in Mirth? How can I invoke ActiveXObject in Mirth? 如何将外部 jar 文件添加到本机应用程序中,并将其用作 javascript 文件中的插件,用于 android 和 iOS - How can I add the external jar file into react native application and use as a plugin into the javascript file for both android and iOS 如何从Javascript运行.jar方法 - How to Run .jar methods from Javascript 在另一个 js 文件中进行 dom 操作后,如何运行 javascript 文件? - How can I run javascript file after dom manipulation made in another js file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM