我在我的系统中安装了ubuntu 10.10并使用以下命令安装了ant: sudo apt-get install ant
现在,ant在共享文件夹中可见,所以我试图在终端中运行ant命令,但它给了我这个错误:
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.
然后我再次设置这些:
JAVA_HOME="/usr/lib/jvm/java-6-sun-1.6.0.22/"
ANT_HOME="/usr/share/ant/"
PATH="/usr/share/ant/bin/"
现在它给了我同样的错误,但在开始时有一个不同的行:
/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.
答案 0 :(得分:33)
尝试以下方法:
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"