Ant: Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher

*爱你&永不变心* 提交于 2019-12-30 05:57:05

问题


I've installed ubuntu 10.10 in my system and installed ant with the following command: sudo apt-get install ant

Now, ant is visible in the share folder, so I've tried to run the ant command in terminal, but it gives me this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
       at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.tools.ant.launch.Launcher.  Program will exit.

Then I set these again:

JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.22/"
ANT_HOME="/usr/share/ant/"
PATH="/usr/share/ant/bin/"

Now it is giving me the same error but with one different line at starting:

/usr/share/ant/bin/ant: 92: uname: not found
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
       at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.apache.tools.ant.launch.Launcher.  Program will exit.

回答1:


try the following:

JAVA_HOME="/usr/lib/jvm/java-6-sun"
ANT_HOME="/usr/share/ant" # do not add "bin" at the end of the path**
PATH="$ANT_HOME/bin:$PATH"


来源:https://stackoverflow.com/questions/4214979/ant-exception-in-thread-main-java-lang-noclassdeffounderror-org-apache-tools

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!