我使用 yum 在 Fedora 5 机器上安装了 Ant,但 Ant 没有启动。我收到此错误消息:
[bash]# 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/java/latest
ANT_HOME = /usr/bin
Ant 安装在/usr/bin/ant
.
我也遇到过这篇文章,似乎该JAVAVER_LIBDIR
变量没有指向存在的东西。我设置了一个符号链接,就像帖子建议为作者清除了问题一样,但它并没有为我解决问题。
[bash]# sudo ln -s /usr/share/java /usr/share/java-1.6.0
编辑:我还设置了一个符号链接,解决了与JAVAVER_JNIDIR
变量类似的问题:
[bash]# sudo ln -s /usr/lib/java /usr/lib/java-1.6.0
我现在收到一条不同的错误消息:
[bash]# ant --execdebug
/usr/bin/build-classpath: error: Could not find jaxp_parser_impl Java extension for this JVM
/usr/bin/build-classpath: error: Could not find xml-commons-apis Java extension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found
exec "/usr/java/latest/bin/java" -classpath "/usr/share/java-1.6.0/ant.jar:/usr/share/java-1.6.0/ant-launcher.jar:/usr/java/latest/lib/tools.jar" -Dant.home="/usr" -Dant.library.dir="/usr/lib" org.apache.tools.ant.launch.Launcher -cp ""
Buildfile: build.xml does not exist!
Build failed
关闭谷歌这些错误消息......