I want to run my Ant script i.e (build.xml) through my java program , following is part of mycode
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("build.xml");
but I'm getting the following error
java.io.IOException: Cannot run program "build.xml": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at com.infotech.RunCmd.main(RunCmd.java:12)
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:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 4 more
How to solve it?
Process proc = rt.exec("PATH/TO/ANT_HOME/ant [options] [target [target2 [target3] ...]]");