1

I have this code:

try {
    Process p = new ProcessBuilder(
            "/Applications/TorBrowser_en-US.app/Contents/MacOS/./tor",
            "-f /Applications/TorBrowser_en-US.app/Library/filetctor/torrc")
            .start();
    p.waitFor();
    int exitVal = p.exitValue();
    System.out.println("Process exitValue: " + exitVal);
} catch (IOException e) {
    System.out.println(e);
} catch (InterruptedException e) {
    System.out.println(e);
}

Every time i execute it, i get a 255 exitValue. The process doesn't run properly.

If i run the program with only:

Process p = new ProcessBuilder("/Applications/TorBrowser_en-US.app/Contents/MacOS/./tor").start();

The process runs correctly. But i need to use the -f option.

What is the problem? Am i writing it incorrectly?

2
  • The -f and the file path should almost certainly be separate parameters. Commented May 27, 2013 at 14:49
  • Did you try to run the application on its own? What error does it return? Try and fetch it with getInputStream() or getErrorStream(). Commented May 27, 2013 at 14:50

1 Answer 1

3

Each argument should be a separate string, not all in a single space-separated string.

See the example in the documentation:

ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2");

Sign up to request clarification or add additional context in comments.

1 Comment

Process p = new ProcessBuilder("/Applications/TorBrowser_en-US.app/Contents/MacOS/./tor", "-f", "/Applications/TorBrowser_en-US.app/Library/filetctor/torrc").start(); WORKS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.