title: Could not find the main class error with Ant
body: <p>It's my first time using Ant and I'm getting a <code>java.lang.NoClassDefFoundError</code> Exception when it tries to run. Here is my Ant build script,</p>
  
  <pre><code>&lt;project name="LearnKirtan" basedir="." default="main"&gt;
  
      &lt;property name="src.dir" value="src" /&gt;
      &lt;property name="lib.dir" value="lib" /&gt;
  
      &lt;property name="build.dir" value="build" /&gt;
      &lt;property name="classes.dir" value="${build.dir}/classes" /&gt;
      &lt;property name="jar.dir" value="${build.dir}/jar" /&gt;
  
      &lt;path id="classpath"&gt;
          &lt;fileset dir="${lib.dir}" includes="**/*.jar" /&gt;
      &lt;/path&gt;
  
      &lt;property name="main-class" value="gsingh.learnkirtan.Main" /&gt;
  
      &lt;target name="clean"&gt;
          &lt;delete dir="${build.dir}" /&gt;
      &lt;/target&gt;
  
      &lt;target name="compile"&gt;
          &lt;mkdir dir="${classes.dir}" /&gt;
          &lt;javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false" classpathref="classpath" /&gt;
      &lt;/target&gt;
  
      &lt;target name="jar" depends="compile"&gt;
          &lt;mkdir dir="${jar.dir}" /&gt;
          &lt;jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"&gt;
              &lt;manifest&gt;
                  &lt;attribute name="Main-Class" value="${main-class}" /&gt;
              &lt;/manifest&gt;
          &lt;/jar&gt;
      &lt;/target&gt;
  
      &lt;target name="run" depends="jar"&gt;
          &lt;java classname="${main-class}" fork="true" /&gt;
          &lt;classpath&gt;
              &lt;path refid="classpath" /&gt;
              &lt;path location="${jar.dir}/${ant.project.name}.jar" /&gt;
          &lt;/classpath&gt;
      &lt;/target&gt;
  
      &lt;target name="clean-build" depends="clean,jar" /&gt;
  
      &lt;target name="main" depends="clean,run" /&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>The build gives no errors. The run target gives the exception. I've checked the manifest generated in the jar file and it looks like this,</p>
  
  <pre><code>Manifest-Version: 1.0
  Ant-Version: Apache Ant 1.8.2
  Created-By: 1.6.0_30-b12 (Sun Microsystems Inc.)
  Main-Class: gsingh.learnkirtan.Main
  </code></pre>