I have looked up on how to run an executable in java via Runtime process builder but it does not work. My code is as follows ...
String command = "potrace --svg mb-finer-19.pbm -o mb-finer-19.svg";
try {
File f = new File("C:\\webstudio\\potrace113win32");
Process process = Runtime.getRuntime().exec(command, null, f);
System.out.println("the output stream is " + process.getOutputStream());
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String s;
while ((s = reader.readLine()) != null) {
System.out.println("The inout stream is " + s);
}
} catch (IOException e) {
e.printStackTrace();
}
but I get back
java.io.IOException: Cannot run program "potrace" (in directory "C:\webstudio\potrace113win32"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:450)
at shellcommands.RunPotrace.main(RunPotrace.java:22)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)```
Where am I going wrong with this as it is according to the javadocs ? The executable portace.exe is in the directory along with the image mb-finer-19.pbm Help will be much appreciated.