找不到 javac 编译器
我正在尝试使用Ant将我的Web应用程序打包到war文件中。
当我构建时,我收到以下错误:
C:\Documents and Settings\Administrator\workspace\Assignment7\build.xml:67: 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.
It is currently set to "C:\Program Files\Java\jre6"
以下是我的构建.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Generate War" default="install" basedir=".">
<property name="build.dir" value="build"/>
<property name="dir.name" value="Assignment7"/>
<property name="package.name" value="${dir.name}.war"/>
<property name="content" value="webContent"/>
<property name="web-inf" value="${content}\WEB-INF"/>
<property name="meta-inf" value="${content}\META-INF"/>
<property name="jsp.dir.name" value="${content}"/>
<property name="lib" value="${web-inf}\lib"/>
<property name="src" value="src"/>
<property name="dest.dir" value="target"/>
<!-- Setting path to the server webapp folder -->
<property name="webapp.dir" value="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps"/>
<!-- Using temp folder for convinence -->
<property name="temp.dir" value="temp"/>
<property name="temp.dir.web-inf" value="${temp.dir}\WEB-INF"/>
<property name="temp.dir.meta-inf" value="${temp.dir}\META-INF"/>
<property name="temp.dir.lib" value="${temp.dir.web-inf}\lib"/>
<property name="temp.dir.classes" value="${temp.dir.web-inf}\classes"/>
<!--<property name="temp.dir.classes.dir" value="${temp.dir.classes}\**"/>-->
<property name="package.file" value="${dest.dir}\${package.name}"/>
<path id="build.class.path">
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="build.class.path1">
<fileset dir="C:\program files\java\jre6\lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="clean">
<delete>
<fileset dir="${dest.dir}" includes="**/*"/>
</delete>
<delete dir="${temp.dir}"/>
<delete dir="${temp.dir.classes}"/>
<delete dir="${temp.dir.web-inf}"/>
<delete dir="${temp.dir.meta-inf}"/>
</target>
<target name="prepare" depends="clean">
<mkdir dir="${dest.dir}"/>
<mkdir dir="${temp.dir}"/>
<mkdir dir="${temp.dir.web-inf}"/>
<mkdir dir="${temp.dir.lib}"/>
<mkdir dir="${temp.dir.classes}"/>
<mkdir dir="${temp.dir.meta-inf}"/>
</target>
<target name="compile" depends="prepare">
<echo>==="complie"===</echo>
<javac srcdir="${src}" destdir="${temp.dir.classes}" debug="on">
<classpath refid="build.class.path"></classpath>
</javac>
<!--<copydir src="${build.dir}\classes" dest="${temp.dir.classes}"/>-->
</target>
<target name="package" depends="compile">
<echo>"PACKAGING THE FILES"</echo>
<copy file="${meta-inf}\MANIFEST.MF" tofile="${temp.dir.meta-inf}\MANIFEST.MF" overwrite="true"/>
<copy file="${web-inf}\web.xml" tofile="${temp.dir.web-inf}\web.xml" overwrite="true"/>
<copy file="${web-inf}\tiles.xml" tofile="${temp.dir.web-inf}\tiles.xml" overwrite="true"/>
<copy todir="${temp.dir.classes}">
<fileset dir="${src}">
<include name="**/*.xml"/>
</fileset>
</copy>
<war destfile="${package.file}" webxml="${temp.dir.web-inf}\web.xml" basedir="${temp.dir}">
<fileset dir="${jsp.dir.name}"/>
<lib dir="${lib}"></lib>
<classes dir="${temp.dir.classes}"></classes>
</war>
</target>
<target name="jsps">
<copy todir="${webapp.dir}\${dir.name}">
<fileset dir="${content}">
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="**/*.css"/>
<include name="**/*.gif"/>
<include name="**/*.jpg"/>
<include name="**/*.png"/>
<include name="**/*.js"/>
</fileset>
</copy>
</target>
<target name="install" depends="package">
<copy file="${package.file}" todir="${webapp.dir}" overwrite="true"/>
</target>
</project>
如何编译没有主类的类文件?
如何设置类路径?
作为参考,我正在使用Eclipse。