title: Unable to find a javac compiler
body: <p>I am trying to package my web application into war file using Ant.</p>
  
  <p>When I build, I am getting the following error:</p>
  
  <pre><code>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"
  </code></pre>
  
  <p>The following is my build.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project name="Generate War" default="install" basedir="."&gt;
  
  
      &lt;property name="build.dir" value="build"/&gt;
      &lt;property name="dir.name" value="Assignment7"/&gt;
      &lt;property name="package.name" value="${dir.name}.war"/&gt;
  
      &lt;property name="content" value="webContent"/&gt;
      &lt;property name="web-inf" value="${content}\WEB-INF"/&gt;
      &lt;property name="meta-inf" value="${content}\META-INF"/&gt;
      &lt;property name="jsp.dir.name" value="${content}"/&gt;
  
      &lt;property name="lib" value="${web-inf}\lib"/&gt;
      &lt;property name="src" value="src"/&gt;
      &lt;property name="dest.dir" value="target"/&gt;
  
      &lt;!-- Setting path to the server webapp folder --&gt;
  
      &lt;property name="webapp.dir" value="C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps"/&gt;
  
      &lt;!--  Using temp folder for convinence --&gt;
  
      &lt;property name="temp.dir" value="temp"/&gt;
      &lt;property name="temp.dir.web-inf" value="${temp.dir}\WEB-INF"/&gt;
      &lt;property name="temp.dir.meta-inf" value="${temp.dir}\META-INF"/&gt;
      &lt;property name="temp.dir.lib" value="${temp.dir.web-inf}\lib"/&gt;
      &lt;property name="temp.dir.classes" value="${temp.dir.web-inf}\classes"/&gt;
      &lt;!--&lt;property name="temp.dir.classes.dir" value="${temp.dir.classes}\**"/&gt;--&gt;
  
      &lt;property name="package.file" value="${dest.dir}\${package.name}"/&gt;
  
      &lt;path id="build.class.path"&gt;
          &lt;fileset dir="${lib}"&gt;
              &lt;include name="**/*.jar"/&gt;
          &lt;/fileset&gt;
      &lt;/path&gt;
      &lt;path id="build.class.path1"&gt;
          &lt;fileset dir="C:\program files\java\jre6\lib"&gt;
              &lt;include name="**/*.jar"/&gt;
          &lt;/fileset&gt;
  
      &lt;/path&gt;
  
      &lt;target name="clean"&gt;
          &lt;delete&gt;
              &lt;fileset dir="${dest.dir}" includes="**/*"/&gt;
          &lt;/delete&gt;
          &lt;delete dir="${temp.dir}"/&gt;
          &lt;delete dir="${temp.dir.classes}"/&gt;
          &lt;delete dir="${temp.dir.web-inf}"/&gt;
          &lt;delete dir="${temp.dir.meta-inf}"/&gt;
      &lt;/target&gt;
  
  
      &lt;target name="prepare" depends="clean"&gt;
          &lt;mkdir dir="${dest.dir}"/&gt;
          &lt;mkdir dir="${temp.dir}"/&gt;
          &lt;mkdir dir="${temp.dir.web-inf}"/&gt;
          &lt;mkdir dir="${temp.dir.lib}"/&gt;
          &lt;mkdir dir="${temp.dir.classes}"/&gt;
          &lt;mkdir dir="${temp.dir.meta-inf}"/&gt;
      &lt;/target&gt;
  
      &lt;target name="compile" depends="prepare"&gt;
          &lt;echo&gt;==="complie"===&lt;/echo&gt;
          &lt;javac srcdir="${src}" destdir="${temp.dir.classes}" debug="on"&gt;
              &lt;classpath refid="build.class.path"&gt;&lt;/classpath&gt; 
          &lt;/javac&gt;
          &lt;!--&lt;copydir src="${build.dir}\classes" dest="${temp.dir.classes}"/&gt;--&gt;
      &lt;/target&gt;
  
      &lt;target name="package" depends="compile"&gt;
          &lt;echo&gt;"PACKAGING THE FILES"&lt;/echo&gt;
              &lt;copy file="${meta-inf}\MANIFEST.MF" tofile="${temp.dir.meta-inf}\MANIFEST.MF" overwrite="true"/&gt;
              &lt;copy file="${web-inf}\web.xml" tofile="${temp.dir.web-inf}\web.xml" overwrite="true"/&gt;
              &lt;copy file="${web-inf}\tiles.xml" tofile="${temp.dir.web-inf}\tiles.xml" overwrite="true"/&gt;
              &lt;copy todir="${temp.dir.classes}"&gt;
                  &lt;fileset dir="${src}"&gt;
                      &lt;include  name="**/*.xml"/&gt;
                  &lt;/fileset&gt;
              &lt;/copy&gt;
  
              &lt;war destfile="${package.file}" webxml="${temp.dir.web-inf}\web.xml" basedir="${temp.dir}"&gt;
                  &lt;fileset dir="${jsp.dir.name}"/&gt;
                  &lt;lib dir="${lib}"&gt;&lt;/lib&gt;
                  &lt;classes dir="${temp.dir.classes}"&gt;&lt;/classes&gt;
              &lt;/war&gt;
      &lt;/target&gt;
  
      &lt;target name="jsps"&gt;
              &lt;copy todir="${webapp.dir}\${dir.name}"&gt;
                  &lt;fileset dir="${content}"&gt;
                      &lt;include name="**/*.jsp"/&gt;
                      &lt;include name="**/*.html"/&gt;
                      &lt;include name="**/*.css"/&gt;
                      &lt;include name="**/*.gif"/&gt;
                      &lt;include name="**/*.jpg"/&gt;
                      &lt;include name="**/*.png"/&gt;
                      &lt;include name="**/*.js"/&gt;
                  &lt;/fileset&gt;
              &lt;/copy&gt;
      &lt;/target&gt;
  
      &lt;target name="install" depends="package"&gt;
              &lt;copy file="${package.file}" todir="${webapp.dir}" overwrite="true"/&gt;
      &lt;/target&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>How can I compile a class file that does not have a main class?</p>
  
  <p>How do I set the class path?</p>
  
  <p>For reference, I am using Eclipse.</p>