有以下build.bat
文件:
echo off
set JAVA_HOME="C:\Program Files\Java\jdk1.6.0_25"
set BUILD_CP="C:\Program Files\Java\jdk1.6.0_25\bin\lib\tools.jar";"C:\Program Files\Java\jdk1.6.0_25\bin";..\devlib\ant.jar;..\devlib\optional.jar;..\devlib\junit.jar;..\devlib\xercesImpl.jar;..\devlib\xmlParserAPIs.jar;
"C:\Program Files\Java\jdk1.6.0_25\bin\java" -classpath %BUILD_CP% org.apache.tools.ant.Main -buildfile build.xml all
set BUILD_CP=
pause
当我运行它时,我得到:
构建失败
file:D:/Development/Java/Frameworks/JMeter/TestDemoIbatis/iBATIS_JPetStore-4.0.5/build/build.xml:29: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
Total time: 0 seconds
Press any key to continue . . .
但我的JAVA_HOME
,设置PATH
正确:
更新:
蚂蚁脚本:
<project name="JPetStore" default="all" basedir=".">
<property file="build.properties"/>
<path id="classpath">
<pathelement location="${src}/"/>
<fileset dir="${lib}" includes="**/*.jar" />
<fileset dir="${devlib}" includes="**/*.jar" />
</path>
<target name="clean" >
<delete dir="${wars}"/>
<delete dir="${webapp}"/>
<delete>
<fileset dir="${src}" >
<include name="**/*.class"/>
</fileset>
</delete>
</target>
<target name="prepare" depends="clean">
<mkdir dir="${wars}"/>
<mkdir dir="${webapp}"/>
<mkdir dir="${webapp}/WEB-INF/classes"/>
<mkdir dir="${webapp}/WEB-INF/lib"/>
</target>
<target name="compile" depends="prepare"> //LINE 29 that fails
<javac srcdir="${src}" destdir="${webapp}/WEB-INF/classes" deprecation="off" debug="${debug}">
<classpath refid="classpath"/>
</javac>
</target>
<target name="assemble.view">
<copy todir="${webapp}">
<fileset dir="${web}">
<include name="**/*.jsp"/>
<include name="**/*.html"/>
</fileset>
</copy>
</target>
<target name="assemble" depends="compile">
<copy todir="${webapp}/WEB-INF/classes">
<fileset dir="${src}" >
<exclude name="**/*.java"/>
<exclude name="**/*.class"/>
</fileset>
</copy>
<copy todir="${webapp}/WEB-INF/lib">
<fileset dir="${lib}" />
</copy>
<copy todir="${webapp}">
<fileset dir="${web}" />
</copy>
</target>
<target name="war" depends="assemble">
<jar jarfile="${wars}/jpetstore.war">
<fileset dir="${webapp}">
<include name="**/*"/>
</fileset>
</jar>
</target>
<target name="all" depends="war" />
</project>
这里有什么问题?我在Windows7/64-bit