I am trying to run an external program with custom arguments placed in text field.
Here is my code:
String customPARAM = textfield.getText();
try {
new ProcessBuilder("MyEXE.exe", "-param1 " + customPARAM).start();
} catch (IOException ex) {
Logger.getLogger(MainMenu.class.getName()).log(Level.SEVERE, null, ex);
}
The problem is that the output doesn't take my customPARAM and it does something like MyEXE.exe -param1.
Instead of a whitespace separate arguments with '
,':See this:
ProcessBuilder(String... command).