buildAnt.bat中的内容ant //就这一句现有一项目,目录为
D:\Tomcat 5.0\webapps\webcode\
其根目录下的 build.xml的内容为<?xml version="1.0" encoding="UTF-8"?>
<project basedir="./" name="xdg" default="all" >
<target name="all">
<antcall target="makeDir"></antcall>
</target>
<target name="makeDir">
<mkdir dir="./hello"/>
</target></project>
现在情况是这样的,在任何一工程中,运行这段代码:
public static void main(String[] args) throws IOException {
Runtime runtime = Runtime.getRuntime();
Process process = null;
//调用runtime来运行可执行程序
process = runtime.exec("D:\\Tomcat 5.0\\webapps\\webcode\\buildAnt.bat");
System.out.println("over");
}
没有问题,会执行antBuild.bat中的ant指令,会自动编译build.xml,在当前目录下生成hello目录
但问题是
Runtime runtime = Runtime.getRuntime();
Process process = null; String filePath = request.getRealPath("buildAnt.bat");
System.out.println(filePath);//打印出来的确是D:\Tomcat 5.0\webapps\webcode\buildAnt.bat process = runtime.exec(filePath);
System.out.println("over");这段代码在Servlet中执行,就会没有任何作用,尽管在控制台打出了"over",但是没有创建任何目录
请教高手,这是怎么回事?
D:\Tomcat 5.0\webapps\webcode\
其根目录下的 build.xml的内容为<?xml version="1.0" encoding="UTF-8"?>
<project basedir="./" name="xdg" default="all" >
<target name="all">
<antcall target="makeDir"></antcall>
</target>
<target name="makeDir">
<mkdir dir="./hello"/>
</target></project>
现在情况是这样的,在任何一工程中,运行这段代码:
public static void main(String[] args) throws IOException {
Runtime runtime = Runtime.getRuntime();
Process process = null;
//调用runtime来运行可执行程序
process = runtime.exec("D:\\Tomcat 5.0\\webapps\\webcode\\buildAnt.bat");
System.out.println("over");
}
没有问题,会执行antBuild.bat中的ant指令,会自动编译build.xml,在当前目录下生成hello目录
但问题是
Runtime runtime = Runtime.getRuntime();
Process process = null; String filePath = request.getRealPath("buildAnt.bat");
System.out.println(filePath);//打印出来的确是D:\Tomcat 5.0\webapps\webcode\buildAnt.bat process = runtime.exec(filePath);
System.out.println("over");这段代码在Servlet中执行,就会没有任何作用,尽管在控制台打出了"over",但是没有创建任何目录
请教高手,这是怎么回事?
里面了,这个贴我也结了