I am creating a command string by adding some strings together. If i debug my application and copy final string from variable it works perfectly in terminal. If try Runtime.getRuntime().exec(cmd1);
where cmd1 is my string it doesn't work, i get error 2 (no such file or directory).
My code looks like this:
String cmd1 = sPath + " \"" + files[i].getPath() + "\" \""
+ files[i].getPath().replace(".wav", "_L.wav") + "\" remix 1";
Process p1 = Runtime.getRuntime().exec(cmd1);
p1.waitFor();
The final cmd1 string is this:
/Users/Me/Downloads/sox-14.4.1/sox "/Users/Me/Desktop/DB/A1199/Klu a1.wav"
"/Users/Me/Desktop/DB/A1199/Klu a1_L.wav" remix 1
Any ideas why i get this error? I tried putting sox path into quotes but it doesn't help.
Ok, i tried this:
String[] cmd1 = new String[4];
cmd1[0] = soxPath;
cmd1[1] = "'" + files[i].getPath() + "'";
cmd1[2] = "'" + files[i].getPath().replace(".wav", "_L.wav") + "'";
cmd1[3] = "remix 1";
ProcessBuilder builder = new ProcessBuilder(cmd1);
builder.redirectErrorStream(true);
System.out.println(builder.command().toString());
final Process p1 = builder.start();
copy(p1.getInputStream(), System.out);
p1.waitFor();
But i still get same results... command works in terminal, but java app throws an error: /Users/Me/NetBeansProjects/DataPrepare/sox/sox FAIL formats: can't open input file "/Users/Me/Desktop/DB/audio.wav"': No such file or directory