Tools. jar is missing when the maven project is compiled

Source: Internet
Author: User
Tags stack trace
[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

 

Solution

 

Step 1:Window-> preferences-> JAVA-> installed jres-> click "add", select the default "Standard VM", and click "next> ", click "directory" on the right of "JRE home" and select the directory c: \ Program Files \ Java \ jdk1.7.0 _ 60 \ JRE. Click "OK" to go back to the "installed jres" interface, select the added "jdk1.7.0 _ 60 ".

Step 2:Window-> preferences-> JAVA-> installed jres->Click "JaveSE-1.7" on the left of the interface, and then select "jdk1.7.0 _ 60" on the right ".

Step 3:Add the following two lines to the <eclipse installation directory>/eclipse. ini file: (Be sure to add them before-startup. Note the following two lines ):
-vmC:\Program Files\Java\jdk1.7.0_60\jre\bin\javaw.exe

Step 4:Restart eclipse. Everything is OK.

Problem Analysis

 

The system has two JRE. The JRE in JDK should be used.

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

The system uses Java/jre7 by default, but this directory does not contain tools. jar. Therefore, you need to use Java/jdk1.7.0 _ 60/JRE. The directory contains the tools. jar package.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.