I was getting this error when trying to do a maven build from within eclipse.
For me, the answer was going to Run -> Run Configurations, selecting the Maven Build I was running (from the left panel). Then, I clicked the JRE tab and selected the option Workspace default JRE