Вопрос

I'm trying to start firefox form a Java program, so far i know how to do that with option as well. But i'm interested in send a specific argument so a javascript add-on could obtain it. For example, i use the command Runtime.getRuntime().exec("/usr/bin/firefox") to start firefox, my goal is to use something like Runtime.getRuntime().exec("/usr/bin/firefox 12345"), where 12345 is my argument and obtain it via a simple add-on.

Is this possible at all? is there another method/way to pass an argument to an add-on on firefox start?

Thanks in advance.

Это было полезно?

Решение 4

In first thank you all for your answers, all of you help me to get this work done. After some more research and thinking of some security issues, i end up using the Java process builder adding an environment variable with the value i want:

    //Initiates the process i'm about to start.
    ProcessBuilder pb = new ProcessBuilder(args);
    //Gets the system environment.
    Map<String, String> env = pb.environment();
    //Register VAR with value Value as an evironment variable in this process context
    env.put("VAR", "Value");
    //Stats the process initiated in the 1st line.
    pb.start();

So with this i can run an application and have environment variables on it's context, now i just want to access them in my JavaScript add-on, simply with this:

    var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsiEnvironment);
    var X = env.get('VAR');

where X will have the value in the environment variable VAR (previous defined in the Java code);

Другие советы

Start firefox with a url that contains your argument.

Use it as Runtime.getRuntime().exec(new String[] {"/usr/bin/firefox", "12345"})

Can't tell you how to get that argument in your Firefox add-on. Maybe modifying your question if that's what you're mainly asking?

I think your functionality would break the security model of firefox. but there are commands that you can use, http://www.binaryturf.com/lesser-firefox-command-line-options/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top