开发者

How to Run an External jar file from within a firefox extension

开发者 https://www.devze.com 2022-12-18 19:56 出处:网络
Here is the code I have so far... // Run the external encryption process var fileExe = Components.classes[\"@mozilla.org/file/local;1\"]

Here is the code I have so far...

        // Run the external encryption process
        var fileExe = Components.classes["@mozilla.org/file/local;1"]
                           .createInstance(Components.interfaces.nsILocalFile);
        fileExe.initWithPath("~/tmp/Encrypt.jar");
        var process = Components.classes["@mozilla.org/process/util;1"]
                          .createInstance(Components.interfaces.nsIProcess);
        process.init(fileExe);
        var args = ["java -jar Encrypt.jar -e toEncrypt"];

        process.run(true, args, args.length);

        document.getElementById('hello-world-status-bar-icon').label = "DONE";

This currently does not work. Any suggestions??

开发者_StackOverflowEDIT I've also tried..

// Run the external encryption process
var fileExe = Components.classes["@mozilla.org/file/local;1"]
                         .createInstance(Components.interfaces.nsILocalFile);
fileExe.initWithPath("java");
var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
        process.init(fileExe);

 var args = new Array();
        args[0] = " -jar";
        args[1] = "~/tmp/Encrypt.jar";
        args[2] = "-e";
        args[3] = "toEncrypt";

        process.run(true, args, args.length);

        document.getElementById('hello-world-status-bar-icon').label = "DONE";

Thanks, Pat


I think you need to init the process with a reference to the local file that is the "java" executable. That's what needs to be executed at the system level. The arguments need to be passed as an array of individual strings, not a single string.

0

精彩评论

暂无评论...
验证码 换一张
取 消