title: Execute TestNG.xml file from Build.xml(ANT)
body: <p>Below is my Build.xml file. I am trying to execute my TestNG.xml through Build.xml but I am getting the below error everytime.</p>
  
  <p><strong>[testng] Cannot find class in classpath:</strong></p>
  
  <p>The below file is working fine till the compile target. I guess there are some issues with the code written in <strong>exec</strong> target.</p>
  
  <p>If I try executing my TestNG.xml file alone, it works perfectly fine. No issues. But the issue comes when I execute my TestNG.xml from Build.xml.</p>
  
  <p>I have tried resolving the issue by a number of methods that I found on stackoverflow such as:</p>
  
  <ul>
  <li>Cleaning the project</li>
  <li>Updating the TestNG library
  but it didn't work out.</li>
  </ul>
  
  <p>Can anybody help me on this ?</p>
  
  <p>
      </p>
  
  <pre><code>&lt;property name="lib" value="./lib" /&gt;
  
  &lt;property name="bin" value="./bin" /&gt;
  
  &lt;path id="Sample Ant build.classpath"&gt;
      &lt;pathelement location="${output}" /&gt;
      &lt;fileset dir="${lib}"&gt;
          &lt;include name="**/*.jar" /&gt;
      &lt;/fileset&gt;
  &lt;/path&gt;
  
  &lt;target name="init"&gt;
      &lt;delete dir="${bin}"&gt;
      &lt;/delete&gt;
      &lt;mkdir dir="${bin}" /&gt;
  &lt;/target&gt;
  
  &lt;target name="compile" depends="init"&gt;
      &lt;javac srcdir="${src}" 
           destdir="${bin}"
          includeantruntime="false"   
           debug="true"&gt;
          &lt;classpath refid="Sample Ant build.classpath"/&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  
  &lt;!-- Runs the file and generates Reportng report for TestNG--&gt;
  &lt;taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="Sample Ant build.classpath" /&gt;
  
  &lt;target name="exec" depends="compile"&gt;
      &lt;mkdir dir="${testng_report_dir}" /&gt;
      &lt;testng outputdir="${testng_report_dir}" classpathref="Sample Ant build.classpath" useDefaultListeners="true"&gt;
          &lt;xmlfileset dir="${basedir}" includes="Testng.xml" /&gt;
      &lt;/testng&gt;
  
  &lt;/target&gt;
  </code></pre>
  
  <p></p>