版本中javac的maven编译器错误:prepare

版本中javac的maven编译器错误:prepare,java,maven,compiler-construction,release,Java,Maven,Compiler Construction,Release,我有这个问题。我看到了很多这样的帖子,但我仍然无法解决这个问题。在shell中放置mvn release:prepare时出现此错误 [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3:compile (default-compile) on project birthday-greeting-card-sender: Compilation failure [INFO]

我有这个问题。我看到了很多这样的帖子,但我仍然无法解决这个问题。在shell中放置mvn release:prepare时出现此错误

[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3:compile (default-compile) on project birthday-greeting-card-sender: Compilation failure
[INFO] [ERROR] Unable to locate the Javac Compiler in:
[INFO] [ERROR] /usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/tools.jar
[INFO] [ERROR] Please ensure you are using JDK 1.4 or above and
[INFO] [ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[INFO] [ERROR] In most cases you can change the location of your Java
[INFO] [ERROR] installation by setting the JAVA_HOME environment variable.
[INFO] [ERROR] -> [Help 1]
[INFO] [ERROR] 
[INFO] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[INFO] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[INFO] [ERROR] 
[INFO] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[INFO] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我已将JDK设置为/usr/lib/jvm/java-7-openjdk-amd64(首选项-->java-->已安装JRE)。我还将这一行添加到eclipse.ini中,但它也无法工作:

-vm /usr/lib/jvm/java-7-openjdk-amd64

有人知道发生了什么吗?

因为在shell中运行mvn时也会遇到这个问题,这与eclipse无关,所以设置:

-vm /usr/lib/jvm/java-7-openjdk-amd64
不会有任何效果

这也与执行目标
release:prepare
无关,因为错误发生在编译时。通过执行
mvn编译
,您可能会重现相同的错误

您的JAVA_主页可能指向
/usr/lib/jvm/JAVA-6-openjdk-amd64
(见mvn日志),而您的jdk位于
/usr/lib/jvm/JAVA-7-openjdk-amd64

要更改JAVA_HOME并测试新设置,请进入shell并执行以下操作:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
mvn compile

如果有效,您可以将
导出JAVA_HOME=/usr/lib/jvm/JAVA-7-openjdk-amd64
添加到
~/.bashrc
文件中,以便每次都设置它。

您的$JAVA_HOME是什么?但我应该在哪里更改它?因为我已经从首选项-->Java-->更改了安装的JRE,而且它似乎没有任何效果,所以我修复了它!我再次下载了jdk,将java_设置在家中并开始工作。谢谢