abdul khan abdul khan - 1 month ago 14
Java Question

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?

Answer

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".

Comments