问题描述
我用yum在Fedora 5台机器上安装了Ant,但蚂蚁不会启动。我得到这个错误信息:
I installed Ant on a Fedora 5 machine using yum, but Ant does not launch. I get this error message:
[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.
我已经设置了以下环境变量:
I have set the following environment variables:
JAVA_HOME = /usr/java/latest
ANT_HOME = /usr/bin
蚂蚁安装在的/ usr /斌/蚂蚁
。
我也碰到过,它似乎是在 JAVAVER_LIBDIR
变量没有指向的东西存在。我设置一个符号链接,像后建议清除问题为作者,但它并没有解决的事情对我来说。
I have also come across this post, and it seems that the JAVAVER_LIBDIR
variable does not point to something that exists. I set a symbolic link, like the post suggests cleared the issue up for the author, but it did not fix things for me.
[bash]# sudo ln -s /usr/share/java /usr/share/java-1.6.0
编辑:我还设置了与 JAVAVER_JNIDIR
变量解决了类似的问题的符号链接:
I have also set a symbolic link that addressed a similar problem with the JAVAVER_JNIDIR
variable:
[bash]# sudo ln -s /usr/lib/java /usr/lib/java-1.6.0
我现在得到一个不同的错误信息:
I now get a different error message:
[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
关以谷歌这些错误消息...
Off to Google these error messages...
推荐答案
我刚刚遇到了类似的问题在Fedora 18。
I've just met similar issue on Fedora 18.
为了使长话短说,运行:
To make long story short, run:
sudo mkdir /usr/lib/java-1.7.0 /usr/share/java-1.7.0
显然,这个问题是特定于的java-1.7.0-的OpenJDK
,因为类似的空的所有其他的JDK版本目录存在。
Apparently, this problem is specific to java-1.7.0-openjdk
because similar empty directories for all other JDK versions existed.
详情
运行后有单行误差蚂蚁
:
Error: Could not find or load main class org.apache.tools.ant.launch.Launcher
问题是在某处的/ usr /共享/ Java的utils的/ Java的功能
脚本试图设置 JAVAVER_JNIDIR
/ JAVAVER_LIBDIR
变量指的就是上述目录。由于不适当的错误信息重定向到stdout,一些变量有像分配:
The problem was somewhere in /usr/share/java-utils/java-functions
script which tried to set JAVAVER_JNIDIR
/JAVAVER_LIBDIR
variables to refer to the directories above. Due to inappropriate error message redirection to stdout, some variables got assignments like:
LOCALCLASSPATH='/usr/bin/build-classpath: error: JAVAVER_JNIDIR /usr/lib/java-1.7.0 does not exist or is not a directory'
根据所有其他的Java版本设置约定创建的目录是干净的解决方案。
Creating the directories according to the convention set by all other java versions is the cleanest solution.
这篇关于有什么不对我的蚂蚁配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!