问题
I am getting this problem while building maven project .. please help me out..
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project Subs_Engine: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [Help 1]
回答1:
If you're getting this in eclipse make sure that Eclipse is pointing to a JDK and Not a JRE.
In Eclipse navigate to Window->Preferences->Java->Installed JRES- Add... Standard VM and point Directory... to a JDK. You'll obviously need to install a JDK if you have not done so.
回答2:
I think you need to point JAVA_HOME to a JDK not just a JRE. The JRE is the java runtime environment while the JDK is for development and will contain the compiler and libs required.
回答3:
Tried all that was mentioned in the above solutions but didn't work. Finally, after scratching up my head for hours, I could do it with below actions:
windows > preferences > installed jres > click edit on the selected jre/jdk > add external jar > add in tools.jar
Hope this helps you save a lot of time. Cheers!
回答4:
I faced that error after update my java version from 1.8.0_201 to 1.8.0_221. In the new folder the tools.jar was missing. I found tools.jar file on previous version under "C:\Program Files\Java\jre1.8.0_201\lib" directory(Assuming java is installed under C:\Program Files). I just copied the file and pasted on "C:\Program Files\Java\jre1.8.0_221\lib". The tools.jar file also can be found on "C:\Program Files\Java\jdk1.8.0_161\lib"(version that I installed) directory. It solved my problems. Not quite sure as it is the perfect solution but it works every time. Hopefully same technique would work for other OS too.
来源:https://stackoverflow.com/questions/26973145/maven-build-error-tools-jar-not-found-in-jre