0

I want to use WordNet and its packages for which I am using wn.exe and need to pass "-n#" argument to it. How do I do it from within my java code which is running on the computer.

***Edit: I have a running a java program and from within that program, I need to pass "-n#" as argument to a native process wn.exe and I need to know to how do I do that.*

PS If it is something stupid, I really regret it.

0

2 Answers 2

1

Use class ProcessBuilder. You can set arguments with command(...).

Runtime.exec() also works, but ProcessBuilder is better.

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

2 Comments

Thanks. But, what do I exactly send as the parameter when I call the ProcessBuilder.command(...)
The first argument to command() is the name of the executable, the rest are the arguments you want to pass to it. In your case something like command("C:\\Programs\\WordNet.exe", "-n#"). The link above is for you so that you can read the documentation where everything is explained.
0

Here example how to work with Process:

public BufferedReader runCommand(String command) throws IOException {
    Process p = Runtime.getRuntime().exec(command);
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

    String line;
    while ((line = input.readLine()) != null) {
        System.out.println(line);
    }
    input.close();
    return input;
}

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.