2 つの引数を指定してコマンド ライン プログラムを実行する必要があります。ただし、作業ディレクトリで実行する必要があります。つまり、「c:\folder\subfolder\command arg1 arg2」ではなく、「command arg1 arg2」です。
ここでの他の質問から、私は Runtime.exec(cmdArray, null, workingDirectory); を使用するようになりました。しかし、「CreateProcessエラー= 2、指定されたファイルが見つかりません」というメッセージが表示され続けます。確認したところ、パスとファイルの両方が存在するため、何が問題なのかわかりません。これが私が使用しているコードです。
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`
次のエラーが表示されます。
java.io.IOException: プログラム "mp3wrap.exe" を実行できません (ディレクトリ "E:\Music\New Folder\zz Concatinate\Clear_10" 内): CreateProcess エラー = 2、指定されたファイルが見つかりません