gpt4 book ai didi

eclipse - 使用 maven 编译时无法定位 Javac 编译器 - Unable to locate the Javac Compiler in :

转载 作者:行者123 更新时间:2023-12-04 21:46:49 26 4
gpt4 key购买 nike

使用 maven 编译时出现编译错误。

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre1.6.0_05\..\lib\tools.jar

所以我设置了 JAVA_HOME环境变量但没有优势。错误似乎是 maven 在 jre 路径中搜索 java 编译器,而不是在 JAVA_HOME .
  • JAVA_HOMEC:\Program Files\Java\jdk1.6.0_05 .
  • 安装的 JRE 是 C:\Program Files\Java\jre1.6.0_05 .
  • 我的 PATH变量是:

  • C:\Program Files\PC Connectivity Solution\;D:\alfrescoplatform\ImageMagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\Wbem;C:\Program Files\ImageMagick-6.7.3-Q16;C:\Program Files\Java\jdk1.6.0_05\bin



    这是我的详细日志
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building SpringMVC Maven Webapp 1.0-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ SpringMVC ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ SpringMVC ---
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 2 source files to D:\Learning\spring-workspace\SpringMVC2.5.6\target\classes
    [INFO] -------------------------------------------------------------
    [ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] Unable to locate the Javac Compiler in:
    C:\Program Files\Java\jre1.6.0_05\..\lib\tools.jar
    Please ensure you are using JDK 1.4 or above and
    not a JRE (the com.sun.tools.javac.Main class is required).
    In most cases you can change the location of your Java
    installation by setting the JAVA_HOME environment variable.
    [INFO] 1 error
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.719s
    [INFO] Finished at: Thu Nov 01 17:22:43 MMT 2012
    [INFO] Final Memory: 4M/8M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project SpringMVC: Compilation failure
    [ERROR] Unable to locate the Javac Compiler in:
    [ERROR] C:\Program Files\Java\jre1.6.0_05\..\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]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    如果您对此有任何想法,请告诉我。

    最佳答案

    你的 JAVA_HOME 是 C:\Program Files\Java\jdk1.6.0_05

    方式一 :以下步骤适用于 Eclipse:

  • 转到窗口 -> 首选项 -> Java -> 已安装的 JRE
  • 将现有 JRE 位置编辑为:Set JRE Home = JAVA_HOME 或 JAVA_HOME\jre(在您的情况下,路径应为 C:\Program Files\Java\jdk1.6.0_05 或 C:\Program Files\Java\jdk1.6.0_05\jre)
  • 单击“完成”和“确定”按钮

  • 方式二 :另一种设置JRE系统库的方法:
  • 打开 eclipse 并右键单击 Eclipse 项目属性
  • Java 构建路径 -> 库
  • 选择 JRE 系统库 -> 单击编辑按钮
  • 单击“已安装 JRE...”按钮
  • 将 JRE 编辑为:设置 JRE Home = JAVA_HOME 或 JAVA_HOME\jre

  • 方式三 :以下步骤也应该可以正常工作:
  • 转到窗口 -> 首选项 -> Java -> 已安装的 JRE
  • 选择您正在使用的 JRE
  • 按编辑 -> 添加外部 JAR...
  • 浏览到 Java\jdk1.6.0_05\lib 并选择 tools.jar 并按 Enter
  • 单击“完成”和“确定”按钮
  • 关于eclipse - 使用 maven 编译时无法定位 Javac 编译器 - Unable to locate the Javac Compiler in :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13175740/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com