Note that there are some explanatory texts on larger screens.

plurals
  1. POAnt: NoClassDefFound exception
    primarykey
    data
    text
    <p>I am developing a java project. My instructor wants us to strictly use apache ant for compilation. I knew nothing about it, and don't know about apache ant either. I have generated an ant buildfile and edited that for target "run", so that program will run after ant run command.</p> <p>I am getting following error,</p> <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: src/Client [java] Caused by: java.lang.ClassNotFoundException: src.Client [java] at java.net.URLClassLoader$1.run(URLClassLoader.java:217) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at java.net.URLClassLoader.findClass(URLClassLoader.java:205) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:321) [java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) [java] at java.lang.ClassLoader.loadClass(ClassLoader.java:266) [java] Could not find the main class: src.Client. Program will exit. </code></pre> <p>I think I have resolved all the target dependencies. But still this error persists.</p> <p>Can somebody help me? This is my ant build.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt; &lt;!-- WARNING: Eclipse auto-generated file. Any modifications will be overwritten. To include a user specific buildfile here, simply create one in the same directory with the processing instruction &lt;?eclipse.ant.import?&gt; as the first entry and export the buildfile again. --&gt; &lt;project basedir="." default="build" name="client"&gt; &lt;property environment="env"/&gt; &lt;property name="ECLIPSE_HOME" value="../../../../usr/lib/eclipse"/&gt; &lt;property name="debuglevel" value="source,lines,vars"/&gt; &lt;property name="target" value="1.6"/&gt; &lt;property name="source" value="1.6"/&gt; &lt;path id="client.classpath"&gt; &lt;pathelement location="bin"/&gt; &lt;pathelement location="libthrift-1.0.0-javadoc.jar"/&gt; &lt;pathelement location="libthrift-1.0.0.jar"/&gt; &lt;pathelement location="log4j-1.2.14.jar"/&gt; &lt;pathelement location="slf4j-api-1.5.8.jar"/&gt; &lt;pathelement location="slf4j-log4j12-1.5.8.jar"/&gt; &lt;/path&gt; &lt;target name="init"&gt; &lt;mkdir dir="bin"/&gt; &lt;mkdir dir="build"/&gt; &lt;copy includeemptydirs="false" todir="bin"&gt; &lt;fileset dir="src"&gt; &lt;exclude name="**/*.java"/&gt; &lt;/fileset&gt; &lt;/copy&gt; &lt;/target&gt; &lt;target name="clean"&gt; &lt;delete dir="bin"/&gt; &lt;/target&gt; &lt;target depends="clean" name="cleanall"/&gt; &lt;target depends="build-subprojects,build-project" name="build"/&gt; &lt;target name="build-subprojects"/&gt; &lt;target depends="init" name="build-project"&gt; &lt;echo message="${ant.project.name}: ${ant.file}"/&gt; &lt;javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}"&gt; &lt;src path="src"/&gt; &lt;classpath refid="client.classpath"/&gt; &lt;/javac&gt; &lt;/target&gt; &lt;target name="jar" depends="init"&gt; &lt;mkdir dir="build/jar" /&gt; &lt;jar destfile="client.jar" basedir="bin"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="src.Client" /&gt; &lt;/manifest&gt; &lt;/jar&gt; &lt;/target&gt; &lt;target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/&gt; &lt;target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler"&gt; &lt;copy todir="${ant.library.dir}"&gt; &lt;fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/&gt; &lt;/copy&gt; &lt;unzip dest="${ant.library.dir}"&gt; &lt;patternset includes="jdtCompilerAdapter.jar"/&gt; &lt;fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/&gt; &lt;/unzip&gt; &lt;/target&gt; &lt;target description="compile project with Eclipse compiler" name="build-eclipse-compiler"&gt; &lt;property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/&gt; &lt;antcall target="build"/&gt; &lt;/target&gt; &lt;target name="Client"&gt; &lt;java classname="Client" failonerror="true" fork="yes"&gt; &lt;classpath refid="client.classpath"/&gt; &lt;/java&gt; &lt;/target&gt; &lt;target name="run" depends="jar"&gt; &lt;java jar="client.jar" fork="true"&gt; &lt;/java&gt; &lt;/target&gt; &lt;/project&gt; </code></pre> <p>Can anybody spot the mistake for me?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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