Maven项目编译时报错缺少tools.jar

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ERP: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\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

 

解决方案


 步骤一Window -> Preferences -> Java -> installed JREs ->点击"Add"按钮,选择默认的"Standard VM", 点击"Next >", 点击"JRE home"右边的"Directory"选择目录 C:\Program Files\Java\jdk1.7.0_60\jre,“确定”回 到"Installed JREs"界面,勾选刚添加的"jdk1.7.0_60"。

步骤二Window -> Preferences -> Java -> installed JREs -> 点选界面左侧的"JaveSE-1.7",然后在右侧勾选"jdk1.7.0_60"。

步骤三在<eclipse安装目录>/eclipse.ini文件中添加以下两行:(一定要加在-startup之前,注意以下是两行):
-vm
C:\Program Files\Java\jdk1.7.0_60\jre\bin\javaw.exe

步骤四重启Eclipse,一切OK了。

 

问题分析


 系统装了两个JRE,应该用JDK中的那个JRE

java
|—jdk1.7.0_60
   |—jre
|—jre7

系统默认使用java/jre7,但是该目录下没有tools.jar。所以需要使用java/jdk1.7.0_60/jre,该目录下存在tools.jar包

转载于:https://www.cnblogs.com/sylvia-liu/p/3812114.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值