Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to execute jar file. Getting NoClassDefFoundError
    text
    copied!<p>I have created a executable jar file using build. </p> <pre><code>&lt;target name="deploy" depends="compile"&gt; &lt;jar jarfile="${deploy.home}/${app.name}.jar" basedir="${build.home}"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="abc.xyz"/&gt; &lt;/manifest&gt; &lt;/jar&gt; </code></pre> <p>Here the xyz call has the main method to execute the whole program..</p> <pre><code>public static void main(String[] args) { File buildFile = new File("build.xml"); Project p = new Project(); p.setUserProperty("ant.file", buildFile.getAbsolutePath()); p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference("ant.projectHelper", helper); helper.parse(p, buildFile); p.executeTarget(p.getDefaultTarget()); } </code></pre> <p>The jar file is being created successfuly. When I execute the like <code>java -jar appname.jar</code>, it is throwing exception -- </p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/Project at abc.xyz.main(xyz.java:20) Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.Project at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) </code></pre> <p>The project class not found. Its there in <code>ant.jar</code>.</p> <p>But when i execute the <code>abc.java</code> class simply by on command prompt java abc its working fine. </p> <p>Pleased help me to get the cause? and its solution. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload