The example in this article describes the way JavaScript invokes the client Java program. Share to everyone for your reference. Specifically as follows:
Generally speaking, JavaScript does not have permission to invoke the client to execute the program. But sometimes there are special needs that have to be invoked. For example, sometimes it involves the operation of the client file, and of course we can do it with the FileSystemObject object. For example, in our previous projects, the need is to click on the page a link does not pop ie file Download dialog box (there are three options: Open, Save, cancel the one), directly download the file to the specified directory. At this point you have to bypass the browser's dialog box, write a client's Java program to achieve the download. This code is tested in IE8, to set your site as a trusted site, and then to enable the "Initialize not marked as Safe ActiveX Control" entry in the Trusted Site security options in the browser.
function Calljava () {
try{
var strpath= "C:\\ajava.jar"; \ client Java program path
var objshell=new activexobject (" Wscript.Shell ");
Window.status= "Operation in progress, please wait ...";
Objshell.run (strpath,8,true); The \ n program blocks this until the client client program returns to
Objshell=null;
Window.status= "Operation ended. ";
} catch (e) {
alert ("Operation failed!) The reason may be that the browser security option is not set incorrectly or the client handler cannot be found.
I hope this article will help you with your JavaScript programming.