[英]Get returned value from jar file using javascript
I have learned run a jar file using ActiveXObject Object in javascript. 我学会了使用JavaScript中的ActiveXObject对象运行jar文件。 Now, I need to get returned value from jar file.
现在,我需要从jar文件中获取返回值。 I can't use 'applet' because project requirement.
由于项目要求,我无法使用“小程序”。
Here is simple coding... 这是简单的编码...
function RunExe(){
w = new ActiveXObject("WScript.Shell");
w.run('C://WindowJar.jar');
return true;
}
How can I get returned value from jar file not using 'applet'. 如何不使用'applet'从jar文件获取返回值。
Thanks your advice. 感谢您的建议。
The only I think this could work is to print the 'returned value' from the jar with the function System.out.println . 我认为这唯一可行的方法是使用功能System.out.println从jar中打印“返回值”。 So you can read this output in the javascript using the code below:
因此,您可以使用以下代码在javascript中读取此输出:
function RunExe(){
w = new ActiveXObject("WScript.Shell");
var ex =w.Exec('C://WindowJar.jar');
var ret = "";
//read the output of the jar
while (!ex.StdOut.AtEndOfStream) {
ret += ex.StdOut.ReadLine();
}
//alert the output
alert(ret)
return true;
}
This answer was based in this question : How can I run a local Windows Application and have the output be piped into the Browser 答案基于以下问题 : 如何运行本地Windows应用程序并将输出通过管道传输到浏览器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.