我想从Java调用build.xml。要做到这一点,我在Java主方法中提到下面的代码:无法从java main方法调用build.xml
Process process;
try {
process = new ProcessBuilder("ant","-f" ,"D:/Selenium/Workspace/test_project/build.xml").start();
process.waitFor();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
} catch (Exception e)
{
e.printStackTrace();
}
但我得到的错误:
java.io.IOException: Cannot run program "ant": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at com.gui.test.TestClass_Base.main(TestClass_Base.java:155)
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>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 2 more
请帮助。