I need to execute a command line program with 2 arguments. However, it must execute in the working directory. i.e. "command arg1 arg2", not "c:\folder\subfolder\command arg1 arg2"
From other questions here, I've gotten up to using Runtime.exec(cmdArray, null, workingDirectory); but I keep getting "CreateProcess error=2, The system cannot find the file specified". I've checked, and both the path and file exist, so I don't know what is going wrong. Here is the code I'm using.
String [] fileName = {"mp3wrap.exe", "Clear_10", "*.mp3"};
String dirName = "E:\\Music\\New Folder\\zz Concatinate\\Clear_10";
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(fileName, null, new File(dirName));
BufferedReader input = new BufferedReader(new InputStreamReader
(pr.getInputStream()));
String line = null;
while ((line = input.readLine()) != null) {
System.out.println(line);
}//end while
int exitVal = pr.waitFor();
System.out.println("Exited with error code " + exitVal);
}//end try
catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}//end catch`
I'm getting this error:
java.io.IOException: Cannot run program "mp3wrap.exe" (in directory "E:\Music\New Folder\zz Concatinate\Clear_10"): CreateProcess error=2, The system cannot find the file specified