title: Ant include external .jar
body: <p>I want to include external jar to my java project. I'm using ant. External .jar is in folder lib. My build.xml looks something like that:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project&gt;
      &lt;path id="classpath"&gt;
          &lt;fileset dir="lib" includes="**/*.jar"/&gt;
      &lt;/path&gt;
  
      &lt;target name="clean"&gt;
          &lt;delete dir="build"/&gt;
      &lt;/target&gt;
  
      &lt;target name="compile"&gt;
          &lt;mkdir dir="build"/&gt;
          &lt;javac srcdir="src" destdir="build" classpathref="classpath" /&gt;
      &lt;/target&gt;
  
      &lt;target name="jar"&gt;
          &lt;mkdir dir="trash"/&gt;
          &lt;jar destfile="trash/test.jar" basedir="build"&gt;
              &lt;zipgroupfileset dir="lib" includes="**/*.jar"/&gt;
              &lt;manifest&gt;
                  &lt;attribute name="Main-Class" value="com.Test"/&gt;
              &lt;/manifest&gt;
          &lt;/jar&gt;
      &lt;/target&gt;
  
      &lt;target name="run"&gt;
          &lt;java jar="trash/test.jar" fork="true"/&gt;
      &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>But it doesn't work. When I want to import something from the external .jar, there is an error after command <code>ant compile</code>: package com.something does not exist.. What should I edit to get it working?</p>
  
  <p>Exact error:</p>
  
  <pre><code>  Compiling 23 source files to xy/build
    xy/src/com/Test.java:5: package com.thoughtworks.xstream does not exist
    import com.thoughtworks.xstream.*;
    ^
    1 error
  </code></pre>