title: How do I put the entire lib directory (including all subdirectories) on the classpath using Ant?
body: <p>I'm not sure this is the problem, but it looks like it might be the case. I'm getting build errors telling me that certain packages don't exist. These packages are packages that exist in .jar files within my lib directory. Any other packages within my java source files that I'm compiling and copying to the classes directory are working just fine. Here are some of the basics of my Ant build script related to this issue:</p>
  
  <pre><code>&lt;property name="app.name" value="myapp" /&gt;
  &lt;property name="base.dir" value="${basedir}" /&gt;
  &lt;property name="build.dir" value="${base.dir}/build" /&gt;
  &lt;property name="build.webinf.dir" value="${build.dir}/WEB-INF" /&gt;
  &lt;property name="build.classes.dir" value="${build.webinf.dir}/classes" /&gt;
  &lt;property name="build.lib.dir" value="${build.webinf.dir}/lib" /&gt;
  &lt;property name="catalina.dir" value="C:\Program Files\Apache Software Foundation\apache-tomcat-5.5.28" /&gt;
  &lt;property name="catalina.lib.dir" value="${catalina.dir}/shared/lib" /&gt;
  &lt;property name="config.dir" value="${base.dir}/config" /&gt;
  &lt;property name="dist.dir" value="${basedir}/dist"/&gt;
  &lt;property name="lib.dir" value="${base.dir}/lib" /&gt;
  &lt;property name="src.dir" value="${base.dir}/src" /&gt;
  &lt;property name="www.dir" value="${base.dir}/www" /&gt;
  
  &lt;path id="compile.classpath"&gt;
      &lt;fileset dir="${lib.dir}"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
      &lt;pathelement location="${catalina.dir}/common/classes" /&gt;
      &lt;fileset dir="${catalina.dir}/common/endorsed"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
      &lt;fileset dir="${catalina.dir}/common/lib"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
      &lt;pathelement location="${catalina.dir}/shared/classes"/&gt;
      &lt;fileset dir="${catalina.lib.dir}"&gt;
          &lt;include name="*.jar" /&gt;
      &lt;/fileset&gt;
  &lt;/path&gt;
  
  &lt;target name="init"&gt;
      &lt;mkdir dir="${build.dir}" /&gt;
      &lt;mkdir dir="${build.webinf.dir}" /&gt;
      &lt;mkdir dir="${build.classes.dir}" /&gt;
      &lt;mkdir dir="${build.lib.dir}" /&gt;
      &lt;mkdir dir="${dist.dir}" /&gt;
      &lt;mkdir dir="${src.dir}" /&gt;
  &lt;/target&gt;
  
  &lt;target name="prepare_www_dir" description="Copies all static web content onto the build path."&gt;
      &lt;copy todir="${build.dir}"&gt;
          &lt;fileset dir="${www.dir}"/&gt;
      &lt;/copy&gt;
  &lt;/target&gt;
  
  &lt;target name="prepare_lib_dir" description="Copies all libraries onto the build lib path."&gt;
      &lt;copy todir="${build.lib.dir}"&gt;
          &lt;fileset dir="${lib.dir}" includes="**/*.jar" /&gt;
      &lt;/copy&gt;
  &lt;/target&gt;
  
  &lt;target name="compile" depends="init,prepare_www_dir,prepare_lib_dir" description="Compiles source code, and copies it onto the build class path."&gt;
      &lt;javac srcdir="${src.dir}" destdir="${build.classes.dir}"&gt;
          &lt;classpath refid="compile.classpath" /&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  </code></pre>