abdul khan
abdul khan

Reputation: 863

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found

I have done all the steps provided in http://www.tutorialspoint.com/jsf/jsf_environment_setup.htm

Apache Maven and Apache tomcat both are ready. I also set the environments. I created Maven project in Eclipse, it gives Build Failure while I run this using Maven build.

It gives this error

"Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project Hello2: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.8.0_40..\lib\tools.jar"

What should I do?

Upvotes: 16

Views: 71460

Answers (5)

ASHISH KARN
ASHISH KARN

Reputation: 131

I am using windows OS with JDK 1.9 in eclipse Oxygen. I faced this issue while compiling the project with JDK 1.9 while using maven and I solved by changing mvn.cmd file present in C:\apache-maven-3.5.2\bin.

Before:

set "JAVACMD=C:\Program Files\Java\jdk-9.0.1\bin\java.exe"

After:

set "JAVACMD=C:\Program Files\Java\jdk1.8.0_91\bin\java.exe"

Also, make sure the compiler you use to build the project is correctly configured in IDE you use.

Upvotes: -1

Divya Dharshini
Divya Dharshini

Reputation: 1

Delete repository from .m2 -> repository and then right click on the project Run as... -> Maven install.

After that, again right click on the project Maven -> Update project -> Check Update of Snapshots and click on the Ok option.

Upvotes: 0

Kun
Kun

Reputation: 580

I delete my .m2 local local repository and re-run it. It works.

Upvotes: 1

Vinayak Dornala
Vinayak Dornala

Reputation: 1679

Check the JAVA version, It should be same across all the places. See screenshots.

  1. pom.xml enter image description here
  2. JAVA build path enter image description here
  3. JAVA compiler enter image description here

Note: To see configuration window for 2 and 3... right click on the project and click properties

Upvotes: 1

Shane Voisard
Shane Voisard

Reputation: 1145

You need to set eclipse's default installed "jre" to a jdk. Eclipse Window Menu => Preferences => enter search string "jre" in left navigation pane => click on "Installed JREs" in left navigation pane => Click Add and browse to your JDK. => click the check box next to the JDK to make it default.

You may need to download and install the java jdk if you don't already have it.

Also ensure the eclipse run configuration is set to use the default jdk you set up: Run Menu => Run Configurations => Select the run config for your project (Maven Build) => Click JRE tab => Under Runtime JRE select "workspace default".

Upvotes: 39

Related Questions