I have a Java project in Eclipse perfectly running smoothly until this afternoon, when I updated some files (including a ant build.xml file). When I build the project, the following error appears:
java.lang.NoClassDefFoundError: proj/absa/FrontEnd/ApplicationStarter Caused by: java.lang.ClassNotFoundException: proj.absa.FrontEnd.ApplicationStarter at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) Exception in thread "main"
Does anyone have a clue where the problem may be?
1) The class is not available in Java Classpath. 2) You might be running your program using the jar command and class was not defined in the manifest file's ClassPath attribute. 3) Any start-up script is an overriding Classpath environment variable. 4) Because NoClassDefFoundError is a subclass of java.
lang. NoClassDefFoundError, which means the Class Loader file responsible for dynamically loading classes can not find the . class file. So to remove this error, you should set your classpath to the location where your Class Loader is present.
The NoClassDefFoundError is a runtime error in Java that occurs if the Java Virtual Machine (JVM) or a ClassLoader instance attempts to load the definition of a class that could not be found. The class definition exists at compile-time but is not available at runtime.
To resolve module dependency, we use the module path. However, adding external jars in the module path does not make them available for the class loader. Hence the class loader considers them as missing dependencies and throws the NoClassDefFoundError.
Doing Project->Clean… in Eclipse solved this problem for me.
java.lang.ClassNotFoundException means CLASSPATH issues. Not having a clue implies that you're assuming that the CLASSPATH is set properly, but it's not.
If you're building with Eclipse, make sure that the directory where your compiled .class files exists, is in the CLASSPATH, and has the necessary .class files in it.
If you're building with Ant, make sure you see something like this in your build.xml:
<path id="production.class.path"> <pathelement location="${production.classes}"/> <pathelement location="${production.resources}"/> <fileset dir="${production.lib}"> <include name="**/*.jar"/> <exclude name="**/junit*.jar"/> <exclude name="**/*test*.jar"/> </fileset> </path>
UPDATE: Either you don't have JAVA_HOME/bin in your PATH or you downloaded the JRE instead of the JDK. Check the directory where you installed Java and see if your /bin directory has javac.exe in it. If you don't have a /bin, download the JDK and install it.
If you do have a /bin with javac.exe in it, check your PATH to see that the Java /bin directory is in the PATH. Once you've set it, open a command shell and type "javac -version" to ensure that all is well.
What JDK did you tell Eclipse to use?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With