在 Eclipse 中设置 $JAVA_HOME 但 ANT 找不到 Java 编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5297146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:58:58  来源:igfitidea点击:

Set $JAVA_HOME in eclipse but ANT Cannot Find Java Compiler

eclipseantjava-home

提问by Shahryar

I add this line to /home/{user}/.bashrcfile:

我将此行添加到/home/{user}/.bashrc文件中:

 export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

but when I want to run an ant file in eclipse got this error:

但是当我想在 Eclipse 中运行 ant 文件时出现此错误:

BUILD FAILED
/home/bakish/Work/new/hadoop-0.20.2/build.xml:316: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"

what should I do?

我该怎么办?

Thanks

谢谢

回答by Alex_M

go to preferences / java / installed jre's -> add a new jre and select the location of your jre/jdk

转到首选项 / java / 已安装的 jre -> 添加新的 jre 并选择 jre/jdk 的位置