I'm trying to do a mysql dump from apache commons-exec and i get the following error
Exception in thread "main" java.io.IOException: Cannot run program "cmd.exe \c" (in directory "."): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:470) at java.lang.Runtime.exec(Runtime.java:593) at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:61) at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:279) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:336) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:153) at com.etq.e2mc.platform.windows.WindowsProcess.execCommons(WindowsProcess.java:87) at com.etq.e2mc.platform.windows.WindowsProcess.main(WindowsProcess.java:79) 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.(ProcessImpl.java:177) at java.lang.ProcessImpl.start(ProcessImpl.java:28) at java.lang.ProcessBuilder.start(ProcessBuilder.java:452) ... 8 more
This is the code i'm using, its pretty simple and straight forward but i can't figure out why it's not invoking the cmd (NOTE: tried with invoking mysql dump directly without the cmd and i get the same type of error), would appreciate any help
public static void main(String[] args) throws Exception {
execCommons();
}
public static void execCommons() throws ExecuteException, IOException {
CommandLine cmd = new CommandLine("cmd.exe /c");
cmd.addArguments("mysqldump");
cmd.addArguments(new String[] { "-u", "root", " -P", "3316", " -h", "localhost", " -A", ">"});
cmd.addArguments("\"G:\\test.sql \"" , false);
new DefaultExecutor().execute(cmd);
}