title: Ant is using the wrong Java Compiler but thinks it's right
body: <p>Just to be clear, this is not this question: <a href="https://stackoverflow.com/questions/949678/ant-is-using-wrong-java-version">Ant is using wrong java version</a></p>
  
  <p>I'm trying to compile a Java 1.7 project using Ant on a Mac OS 10.8.2 machine. I've got Java 1.7 installed, and Eclipse has been building it swimmingly. However, when using an ant build script with command line execution of Ant like so</p>
  
  <pre><code>ant -v
  </code></pre>
  
  <p>the output is mysterious at best: The first lines reveal that Ant is using Java 1.7 as requested, from the location of $JAVA_HOME, as I set up myself. </p>
  
  <pre><code>Apache Ant(TM) version 1.8.2 compiled on December 20 2010
  Trying the default build file: build.xml
  Buildfile: /Users/emish/School/cis555/homework/cis-555-search-engine/build.xml
  Detected Java version: 1.7 in: /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre
  Detected OS: Mac OS X
  </code></pre>
  
  <p>However, the following compiler errors make no sense, because they reveal a compiler error that would only occur in a version prior to Java 1.7: </p>
  
  <pre><code>[javac] /Users/emish/School/cis555/homework/cis-555-search-engine/src/pokedex/crawler/CrawlCore.java:186: &lt;identifier&gt; expected
  [javac]         } catch (IOException | ClassNotFoundException | InterruptedException e) {
  [javac]                             ^
  </code></pre>
  
  <p>This is very weird. I've tried many things, including re-installing my Java JDK and reinstalling Ant. Does anyone out there have some insight into what might be causing this puzzling problem?</p>
  
  <p>If it's any help: </p>
  
  <pre><code>java -version
  java version "1.7.0_17"
  Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
  Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
  
  javac -version
  javac 1.7.0_17
  
  echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home
  
  ll `which javac`
  lrwxr-xr-x  1 root  wheel  75 Oct 30 22:27 /usr/bin/javac -&gt; /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
  
  ll `which java`
  lrwxr-xr-x  1 root  wheel  74 Oct 30 22:27 /usr/bin/java -&gt; /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
  </code></pre>
  
  <p>Edit: As requested by commenters, I've added my build.xml and manifest.mf files below.</p>
  
  <p>build.xml</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  
  &lt;project name="pokedex" default="jar" basedir="."&gt;
      &lt;property name="shared.root" location="${basedir}"/&gt;
      &lt;property name="project.root" location="${basedir}"/&gt;
      &lt;property name="build.dir" location="${project.root}${file.separator}build"/&gt;
      &lt;property name="src" location="${project.root}${file.separator}src"/&gt;
      &lt;property name="build.classes" location="${build.dir}${file.separator}classes"/&gt;
      &lt;property name="test.classes" location="${build.classes}${file.separator}test"/&gt;
      &lt;property name="test.source" location="${src}${file.separator}test"/&gt;
      &lt;property name="lib.dir" location="${project.root}${file.separator}lib"/&gt;
  
  
      &lt;target name="jar" depends="clobber, compile" description="Create Jar file"&gt;
            &lt;jar destfile="pokedex.jar"&gt;
              &lt;fileset dir="${build.classes}" includes="**/*.class"/&gt;
              &lt;fileset dir="${project.root}" includes="conf/*"/&gt;
            &lt;/jar&gt;
      &lt;/target&gt;
  
      &lt;target name="compile" depends="clobber" description="compiles Java source code"&gt;
          &lt;javac srcdir="${src}${file.separator}" destdir="${build.classes}" debug="on" deprecation="off"
              optimize="on" includeAntRuntime="no"&gt;
              &lt;classpath&gt;
                  &lt;fileset dir="${lib.dir}"&gt;
                      &lt;include name="*.jar"/&gt;
                      &lt;include name="*.zip"/&gt;
                  &lt;/fileset&gt;
              &lt;/classpath&gt;
          &lt;/javac&gt;
      &lt;/target&gt;
  
      &lt;target name="pack" depends="jar" description="Create an archive use on EC2"&gt;
            &lt;zip destfile="pokedex.zip"&gt;
              &lt;zipfileset dir="." excludes="target/**,extra/**,**/*.class,pokedex.zip"/&gt;
            &lt;/zip&gt;
      &lt;/target&gt;
  
    &lt;target name="clobber" description="remove jar"&gt;
          &lt;delete file="${project.root}${file.separator}pokedex.jar"/&gt;
          &lt;delete dir="${build.classes}${file.separator}"/&gt;
          &lt;mkdir dir="${build.classes}${file.separator}"/&gt;
      &lt;/target&gt;
  
         &lt;!--DOES NOT WORK --&gt;
         &lt;target name="test" description="Run tests"&gt;
           &lt;java failonerror="true" fork="true" classname="junit.textui.TestRunner"&gt;
             &lt;classpath&gt;
               &lt;pathelement location="${test.classes}"/&gt;
               &lt;pathelement location="${build.classes.dir}"/&gt;
                &lt;fileset dir="${lib.dir}"&gt;
                    &lt;include name="*.jar"/&gt;
                &lt;/fileset&gt;
             &lt;/classpath&gt;
              &lt;arg value="RunAllTests"/&gt;
           &lt;/java&gt;
         &lt;/target&gt;
  
      &lt;target name="test2"&gt;
        &lt;junit&gt;
          &lt;classpath&gt;
               &lt;pathelement location="${build.classes.dir}"/&gt;
                  &lt;fileset dir="${lib.dir}"&gt;
                       &lt;include name="*.jar"/&gt;
                  &lt;/fileset&gt;
                &lt;/classpath&gt;   
          &lt;batchtest&gt;
             &lt;fileset dir="${project.root}"&gt;
                  &lt;include name="**/RunAllTests*" /&gt;
             &lt;/fileset&gt;
          &lt;/batchtest&gt;
          &lt;formatter type="brief" usefile="false"/&gt;
        &lt;/junit&gt;
      &lt;/target&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>manifest.mf</p>
  
  <pre><code>Manifest-Version: 1.0
  Class-Path: 
  </code></pre>