Java – NoClassDefFoundError does not have any class name

I tried to run Java tasks from ants I'm trying to run the "org. Apache. Tools. Ant. Launch. Launcher" class I keep getting "NoClassDefFoundError" without specifying any class name I also get a "classnotfoundexception" and display a message "main class not found:. Program will exit" This is an incorrect code snippet

[java] Exception in thread "main" java.lang.NoClassDefFoundError: 
 [java] Caused by: java.lang.ClassNotFoundException: 
 [java]  at java.net.urlclassloader$1.run(urlclassloader.java:200)
 [java]  at java.s@R_404_1360@.AccessController.doPrivileged(Native Method)
 [java]  at java.net.urlclassloader.findClass(urlclassloader.java:188)
 [java]  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 [java]  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 [java]  at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
 [java]  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
 [java] Could not find the main class: .  Program will exit.
 [java] Java Result: 1

Now I try to run an ant class from an ant jar. I specify the classpath where the class file is located and use the "classpathref" attribute, but I still receive this message I checked the ant jar to check the manifest and correctly specified the "main" class (it is "org. Apache. Tools. Ant. Launch. Launcher") I exhausted all my resources Please help!

PS: my environment is eclipse on Ubuntu 9.04

Solution

Your classpath is most likely incorrectly configured

As a minimum, classpath shall include:

> ant. Jar and ant launcher Jar > jar / class of your XML parser > jar / zip file required for JDK

(from ant manual)

In addition, you seem to restart ant in the current directory (execute the same build. XML) Maybe you want to set the "dir" attribute

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>