简体   繁体   中英

Get returned value from jar file using javascript

I have learned run a jar file using ActiveXObject Object in javascript. Now, I need to get returned value from jar file. 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'.

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 . So you can read this output in the javascript using the code below:

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

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