title: "testng doesn't support the nested "java" element."- while executing build.xml - JAR target
body: <p>We wanted to create Jar, deploy and execute the jar file from the remote machine. </p>
  
  <p>As the provision from the testNG created main class file </p>
  
  <p>When running from this class file its perfectly executing, but when are executing form build XML getting the following error </p>
  
  <blockquote>
    <p>"testng doesn't support the nested "java" element."</p>
    
    <ol>
    <li>TestNG version - 6.13.1 (tried with lower versions too)</li>
    <li>Eclipse - Neon.3 Release (4.6.3)</li>
    <li>Selenium - 3.7.1</li>
    <li>Ant  - 1.10.1</li>
    </ol>
  </blockquote>
  
  <p>After searching for long time and with different possibilities, i am not able to get the solution for this.</p>
  
  <pre class="lang-java prettyprint-override"><code>public static void main(String[] args) {
  
      // Create object of TestNG Class
      TestNG runner = new TestNG();
  
      // Create a list of String
      List&lt;String&gt; suitefiles = new ArrayList&lt;String&gt;();
  
      // Add xml file which you have to execute
      suitefiles.add("D:\\Projects\\TestAutomation\\AgainFinal_Jartest\\TestNG.xml");
  
      // now set xml file for execution
      runner.setTestSuites(suitefiles);
  
      // finally execute the runner using run method
      runner.run();
  }
  </code></pre>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!-- compile --&gt;
  &lt;target name="compile" depends="init, clean" &gt; 
      &lt;delete includeemptydirs="true" quiet="true"&gt;
          &lt;fileset dir="${test.dest}" includes="**/*"/&gt;
      &lt;/delete&gt;
      &lt;echo message="making directory..."/&gt;
      &lt;mkdir dir="${test.dest}"/&gt;
      &lt;echo message="classpath------: ${test.classpath}"/&gt;
      &lt;echo message="compiling..."/&gt;
      &lt;javac debug="true" destdir="${test.dest}" srcdir="${test.src}" target="1.8" classpath="${test.classpath}" includeantruntime="false"&gt;
      &lt;/javac&gt;
  &lt;/target&gt;
  
  &lt;target name="JarCreation" depends="compile" description="package, output to JAR"&gt;
      &lt;!-- Create the distribution directory --&gt;
      &lt;mkdir dir="${jar.dir}" /&gt;
      &lt;echo message="Creating Jarfile ..!"/&gt;
  
      &lt;!-- Put everything in ${build} into the {$ws.project.name}.jar file --&gt;
      &lt;jar jarfile="${jar.dir}/${ws.project.name}.jar" basedir="${basedir}" &gt;
          &lt;manifest&gt;
          &lt;!-- create an executable Jar --&gt;
              &lt;attribute name="Main-Class" value="MyWorld.MainTestNGClass"/&gt;
              &lt;attribute name="Class-Path" value="."/&gt;
          &lt;/manifest&gt;
          &lt;fileset dir="build"/&gt;    
  
      &lt;/jar&gt;
      &lt;echo message="Created an executable Jarfile ..!"/&gt; 
  &lt;/target&gt; 
  
  &lt;!-- build --&gt;
  &lt;target name="build" depends="init"&gt;
  &lt;/target&gt;
  
  &lt;target name="run" depends="compile"&gt;
      &lt;java classname="MyWorld.MainTestNGClass" fork="true"&gt;&lt;/java&gt;
      &lt;sysproperty key="env.key" value="CK_AUTO_DEV"&gt;&lt;/sysproperty&gt;
  &lt;/target&gt;
  
  &lt;target name="runs" depends="compile,JarCreation"&gt;
      &lt;testng classpath="./libs/testng-6.13.1.jar" suitename="Framework for Desktop website"&gt;         
          &lt;java jar="${jar.dir}/${ws.project.name}.jar" fork="true"/&gt;
          &lt;sysproperty key="env.key" value="CK_AUTO_DEV"&gt;&lt;/sysproperty&gt;
      &lt;/testng&gt;
  &lt;/target&gt;
  </code></pre>