使用java home在maven中编译错误
我正在 Fedora 上工作,我的 java 主目录设置为:
export JAVA_HOME=/home/UserName/java
export M3_HOME=/home/UserName/softwares/apache-maven-3.0.3
export PATH=$PATH:/home/UserName/java/bin:/home/Udeshika/softwares/apache-maven-3.0.3/bin
,则会收到以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project viewer: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /home/UserName/java/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR]
现在,当我尝试为 Maven 项目运行 mvn install
时,如果我检查我的 Maven 版本
Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: /home/UserName/softwares/apache-maven-3.0.3
Java version: 1.6.0_07, vendor: Sun Microsystems Inc.
Java home: /home/UserName/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.34.9-69.fc13.i686.pae", arch: "i386", family: "unix"
这里 maven 告诉我的 JAVA_HOME是
Java 主目录:/home/UserName/java/jre
我想我已经确定了问题,现在我不知道如何解决它,任何人都可以指导我解决这个问题吗?
先感谢您
I'm working on Fedora, my java home is set as :
export JAVA_HOME=/home/UserName/java
export M3_HOME=/home/UserName/softwares/apache-maven-3.0.3
export PATH=$PATH:/home/UserName/java/bin:/home/Udeshika/softwares/apache-maven-3.0.3/bin
Now when I try to run mvn install
for maven project, I'm getting following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project viewer: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /home/UserName/java/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR]
if I check my maven version
Apache Maven 3.0.3 (r1075438; 2011-02-28 23:01:09+0530)
Maven home: /home/UserName/softwares/apache-maven-3.0.3
Java version: 1.6.0_07, vendor: Sun Microsystems Inc.
Java home: /home/UserName/java/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.34.9-69.fc13.i686.pae", arch: "i386", family: "unix"
Here maven tells my JAVA_HOME is
Java home: /home/UserName/java/jre
I think I have identified the problem now I don't know to solve it can anyone guide me to solve this problem ??
Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要有一个 Java SDK 才能使用 Maven。 SDK包含tools.jar并允许您编译,而JRE只是一个运行时。
You need to have a Java SDK in order to use Maven. The SDK contains the tools.jar and allows you to compile, whereas the JRE is just a runtime.