I need to run a native windows executable with some parameters:
ProcessBuilder pb = new ProcessBuilder(
programFolder + SUB_PATH,
params);
pb.redirectErrorStream(true);
try {
System.out.println("running...");
Process p = pb.start();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()))) {
String in = null;
while (p.isAlive() && (in = reader.readLine()) != null) {
System.out.println(in);
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
This doesn't seem to work.
I checked that the generated command is correct and running fine when executed manually, but it seem like the above Process
isn't executed at all and no error
's or Exception
's are throw
'n.
What am I missing here?
EDIT: my problem isn't that the executable
is not found but it's just not running.
EDIT: params
value is:
String params = String.format("%d %s %s %s %d %d %d %d %d %d %d %d",
3,
videoPath,
bgImagePath,
distPath,
x1, y1, w1, h1,
x2, y2, w2, h2);
UPDATE: I replaced the ProcessBuilder
with:
Process p = Runtime.getRuntime().exec(programFolder + SUB_PATH + " " + params, null, programDir);
and it now works fine...
I still want to know Why using the ProcessBuilder
did not work?