title: ANT problem with jar file
body: <p>I am having a problem producing a working jar file. I would like to end up with a jar file that can run itself by using the command java -jar myjar.jar</p>
  
  <p>So far I have</p>
  
  <pre><code>&lt;project default="jar" name="Create Runnable Jar fecrudbreset"&gt;
  &lt;target name="clean"&gt;
      &lt;delete dir="bin"/&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"&gt;
          &lt;classpath&gt;
              &lt;pathelement location="./lib/sqljdbc4.jar"/&gt;
          &lt;/classpath&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  &lt;target name="jar" depends="compile"&gt;
      &lt;mkdir dir="./bin"/&gt;
      &lt;jar destfile="./bin/fecrudbreset.jar" &gt;
          &lt;manifest&gt;
              &lt;attribute name="Main-Class" value="FecruDBreset"/&gt;
              &lt;attribute name="Class-Path" value="."/&gt; 
              &lt;attribute name="Built-By" value="${user.name}"/&gt;
          &lt;/manifest&gt;
          &lt;fileset dir="./build"/&gt;
          &lt;zipfileset dir="./lib" includes="sqljdbc4.jar"/&gt;
      &lt;/jar&gt;
  &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The compile works however when I try to run the app I get the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/microsoft/sqlserver/jdbc/SQLServerDataSource
      at FecruDBreset.main(Unknown Source)
  </code></pre>
  
  <p>update:
  The main class I have uses the default package. The class is found and starts to run but fails when it cant locate the sql driver it seems. I guess I dont understand why it cant find it.</p>
  
  <p>Here is how the main class is defined:</p>
  
  <pre><code>import java.sql.*;
  import com.microsoft.sqlserver.jdbc.*;
  
  public class FecruDBreset
  {
  
  /*
   * Used to reset / nuke fecru database
   */
  public static void main(String[] args)
  {
  </code></pre>
  
  <p>Also if I unzip the jar file that is produced the contents look like this:</p>
  
  <pre><code>META-INF/
  META-INF/MANIFEST.MF
  FecruDBreset.class
  sqljdbc4.jar
  </code></pre>
  
  <p>Update 2: My source tree looks like this:</p>
  
  <pre><code>|-- bin
  |   `-- fecrudbreset.jar
  |-- build
  |   `-- FecruDBreset.class
  |-- build.xml
  |-- lib
  |   `-- sqljdbc4.jar
  |-- readme.txt
  `-- src
      `-- FecruDBreset.java
  </code></pre>
  
  <p>Anyone have any idea what I am doing wrong? Thanks much in advance.
  Chad</p>