Running use ant in java <p>Both compilation and JAR file creation is sucessful.</p> <p>Running java file through ant file is producing error.</p> <pre><code>&lt;project&gt; &lt;target name="clean"&gt; &lt;delete dir="build"/&gt; &lt;/target&gt; &lt;target name="compile"&gt; &lt;mkdir dir="build/classes"/&gt; &lt;javac srcdir="src" destdir="build/classes"/&gt; &lt;/target&gt; &lt;target name="jar"&gt; &lt;mkdir dir="build/jar"/&gt; &lt;jar destfile="build/jar/Helloworld" basedir="build/classes"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="Helloworld"/&gt; &lt;/manifest&gt; &lt;/jar&gt; &lt;/target&gt; &lt;target name="run"&gt; &lt;java jar="build/jar/Helloworld" fork="true"/&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>Buildfile: <code>C:\Workspace\anttest\build.xml</code></p> <pre><code>run: [java] java.lang.NoClassDefFoundError: Helloworld [java] Caused by: java.lang.ClassNotFoundException: Helloworld [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:190) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:306) [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:247) [java] Could not find the main class: Helloworld. Program will exit. [java] Exception in thread "main" [java] Java Result: 1 </code></pre> <p>BUILD SUCCESSFUL</p>