Maven报错: Unable to locate the Javac Compiler in: D:\Program\java\jre1.7.0_45\..\lib\tools.jar

使用Eclipse Mars 新建Maven项目,出现以下错误:


[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_hello 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ maven_hello ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory F:\workspace\workspace_mars\maven_hello\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ maven_hello ---
[INFO] Compiling 2 source files to F:\workspace\workspace_mars\maven_hello\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  D:\Program\java\jre1.7.0_45\..\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: 0.888s
[INFO] Finished at: Wed Mar 09 11:56:53 CST 2016
[INFO] Final Memory: 6M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project maven_hello: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] D:\Program\java\jre1.7.0_45\..\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

注意:主要错误信息在这里, 

  Unable to locate the Javac Compiler in:
  D:\Program\java\jre1.7.0_45\..\lib\tools.jar

 没有在以上路径中找到 toor.jar , 我查看自己的安装路径发现,jre1.7.0_45的外层目录中没有lib 文件夹,也就无法找到toor.jar包。原来当初安装JDK和JRE的时候,JRE单独安装在了外面。在JRE同一级目录中并没有JDK的lib包。所以找不到toor.jar 



然后,在Eclipse中重新配置JRE如下:

修改为这个JRE后,同一级目录下能够lib 包下的toor.jar。 然后再次用Maven编译,通过!




  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值