使用java home在maven中编译错误

发布于 2025-01-06 07:52:14 字数 1434 浏览 2 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感受沵的脚步 2025-01-13 07:52:14

您需要有一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文