I am trying to run a jar file from a Java program and I succeed using getRuntime()
:
Process processAlgo = Runtime.getRuntime().exec("java -jar "+algoPath);
However when I try using ProcessBuilder
I get the The system cannot find the file specified
exception:
ProcessBuilder builder = new ProcessBuilder("java -jar " + algoPath);
Process processAlgo = builder.start();
I tried to change the location of the specified file and also indicated its full path but it won't work. What could cause the problem?