title: Ant javac classpathref not working?
body: <p>The <code>javac</code> task in my <code>compile</code> target fails despite the required jars being on the classpath. Could anyone help me figure out why this is happening?</p>
  
  <p>The error below is caused because <code>IOUtils.lineIterator()</code> is not recognized. However, <strong>commons-io-1.3.1.jar</strong> is on the build path (in <code>${app.lib.dir}</code>). So, it's strange that the build fails.</p>
  
  <pre><code>&lt;target name="compile"&gt;
      &lt;mkdir dir="${classes.dir}" /&gt;
      &lt;javac destdir="${classes.dir}" debug="true" classpathref="dependency.path"
          excludes="/../security/**" &gt;
          &lt;src path="${java.src.dir}" /&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  
  &lt;path id="dependency.path"&gt;
      &lt;fileset dir="${spring.lib.dir}" includes="*.jar" /&gt;
      &lt;fileset dir="${spring.depends.dir}" includes="**/*.jar" /&gt;
      &lt;fileset dir="${app.lib.dir}" includes="*.jar" /&gt;
      &lt;fileset dir="${tomcat.dir}/.." includes="**/*.jar" /&gt;
  &lt;/path&gt;
  </code></pre>
  
  <h3>Execution</h3>
  
  <pre><code>ant -f build-dev.xml compile
  
  Buildfile: C:\..\build-dev.xml compile:
      [mkdir] Created dir: C:\..\classes
      [javac] Compiling 348 source files to C:\..\classes
      [javac] C:\..\UploadUtil.java:132: cannot find symbol
      [javac] symbol  : method lineIterator(java.io.InputStream,java.lang.String)
      [javac] location: class org.apache.commons.io.IOUtils
      [javac]             Iterator&lt;String&gt; it = IOUtils.lineIterator(is, charSet);
      [javac]                                          ^
      [javac] Note: Some input files use or override a deprecated API.
      [javac] Note: Recompile with -Xlint:deprecation for details.
      [javac] Note: Some input files use unchecked or unsafe operations.
      [javac] Note: Recompile with -Xlint:unchecked for details.
      [javac] 1 error
  
  BUILD FAILED
  C:\..\build-dev.xml:54: Compile failed; see the compiler error output for details.
  
  Total time: 11 seconds
  </code></pre>
  
  <h3>Approaches tried</h3>
  
  <ol>
  <li><strong>Eclipse</strong>, surprisingly, is building the project without any problem. I have the same set of jars on the project build path. I also have the same source directory excluded from the compilation.</li>
  <li>Attempted to use <strong>javac</strong> executable on the source folder, but not sure how to use javac on a source-code directory structure.</li>
  <li>I'm sure the version of the jar I have has the class <code>IOUtils</code> because Eclipse shows it in the contents of the jar. </li>
  </ol>