You need to run build with JDK or have tools.jar on the classpath.If this occures during eclipse build make sure you run eclipse under JDK as well
Make sure you uninstall the older version of Java from your computer
I had Java 7 installed and then I installed Java 8 on top of it. Go to Program Features and remove all Java 7s.
Launch Eclipse with your JDK:
in eclipse.ini, add -vm [path to your 1.8 jdk] ABOVE -vmargs
In Eclipse, open Window > Perference > type Installed JREs
Add your JDK there as a Standard VM, ensure it is checked, apply.
If your maven project still give you the error, add the jdk to the build path of your project
Right click your project > Build Path > Configure Build Path > go to Libraries tab
Add Library > find your jdk that you added to Eclipse
move the JDK to the top, remove other JRE from the build path window.
My maven project can build without error now. 🙂