Reputation: 171
Issue: The following problem occurs when I compile my project w/ maven (note: I'm working on windows):
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project XYZ: Fatal error compiling: tools.jar not found: C:\java\jdk1.8.0_40..\lib\tools.jar -> [Help 1]
Error occurs from both command line and eclipse (Eclipse STS) - mvn clean; mvn install
Notes:
Upvotes: 6
Views: 40074
Reputation: 1
I don't know whether this will help or not, I had a similar type of issue:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project XYZ: Fatal error compiling: tools.jar not found: C:\java\jre1.8.0_271..\lib\tools.jar -> [Help 1].
So I searched for tools.jar in jdk/lib and found it. I copied it from jdk lib to jre lib folder. I restarted my sts and it worked fine.
Upvotes: 0
Reputation: 1670
Even after configuring Eclipse to use a JDK from Window -> Preferences -> Java -> Installed JRES, you may still get errors when you try to perform a Maven build.
In this case make sure that the JRE tab in Maven Build is configured correctly.
Go to Run -> Run Configurations, open the Maven Build category and do one of the following:
Upvotes: 2
Reputation: 5
Make sure if Eclipse is pointing to a JDK and Not a JRE. For that : Window ==> Preferences ==> Java ==> Installed JRES ==> Add button ==> Standard VM and add your JDK path . This worked.
Upvotes: 0
Reputation: 85
When I added the JDK to the Libraries the problem was solved. The issue is like tools.jar is not found as part of the jre distribution
Upvotes: 0
Reputation: 886
Make sure if Eclipse is pointing to a JDK and Not a JRE. For that : Window ==> Preferences ==> Java ==> Installed JRES ==> Add button ==> Standard VM and add your JDK path .
Upvotes: 0
Reputation: 11
If tools.jar is not found, try adding it up in your project's dependencies on eclipse.
Firstly, copy the location of tools.jar which would look something like this C:\Program Files\Java\jdk1.x.x\lib
Then, on eclipse, Right click your project and go to Properties -> Java Build Path -> Libraries
Click on ADD External JARs button.
Paste the link you have copied above on File Name link bar and click OK button.
Now, tools.jar should be listed on Libraries.
Click okay to close the window.
Now, run the Maven install.
This worked for me.
Upvotes: 1
Reputation: 1896
I also faced similar issue when building the project in eclipse ( sts version) I figured out the issue was because I had jre installed in 2 locations and I jre configured in the eclipse was pointing to the pure jre folder. So just check that your jre is pointing to the jre folder inside the jdk not any other jre as the tools.jar is in jdk/lib
Upvotes: 5
Reputation: 171
Issue resolved: Setting System env variable, JAVA_HOME, to Java JDK 1.7 fixed the problem.
I tried jdk1.7.0_45 and jdk1.7.0_75 - they both worked.
Notes:
Upvotes: 9