Call an executable and pass parameters
Pass your arguments in constructor itself. Process process = new ProcessBuilder(“C:\\PathToExe\\MyExe.exe”,”param1″,”param2″).start();
Pass your arguments in constructor itself. Process process = new ProcessBuilder(“C:\\PathToExe\\MyExe.exe”,”param1″,”param2″).start();
Use ProcessBuilder.inheritIO, it sets the source and destination for subprocess standard I/O to be the same as those of the current Java process. Process p = new ProcessBuilder().inheritIO().command(“command1”).start(); If Java 7 is not an option public static void main(String[] args) throws Exception { Process p = Runtime.getRuntime().exec(“cmd /c dir”); inheritIO(p.getInputStream(), System.out); inheritIO(p.getErrorStream(), System.err); } private … Read more
The various overloads of Runtime.getRuntime().exec(…) take either an array of strings or a single string. The single-string overloads of exec() will tokenise the string into an array of arguments, before passing the string array onto one of the exec() overloads that takes a string array. The ProcessBuilder constructors, on the other hand, only take a … Read more