2

I'd like to start this specific programm with parameter-lines How could I execute this programm with parameters in Java? I'm a newbie, I've been searching hours for a solution.

"C:/Program Files/MyPrograms/MyFile.exe" -s 3 -n 100 (what ever these parameter lines mean now)

I'm sucessfully able to launch my application, without parameters.

code:

String directoryFile = "C:/Program Files/MyPrograms/MyFile.exe"

Desktop.getDesktop().open(new File(directoryFile));

What I want:

String directoryFile = "C:/Program Files/MyPrograms/MyFile.exe"

Desktop.getDesktop().open(new File(directoryFile)+"-s 3 -n 100");

Thanks

4

1 回答 1

4

使用ProcessBuilder,分别传递每个命令行参数

Process p = new ProcessBuilder("C:\\path\\to\\.exe",
                                  "key1", "value1",
                                  "key2", "value2") // etc.
                              .start();
于 2013-11-10T21:02:49.277 回答