For me the issue was that when I installed from jdk-8u25-macosx-x64.dmg
the installation did not update the /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
directory link to the new 1.8 JDK. This may not have been the issue of the original question but it was the solution for me when I encountered the same error message.
I don’t know why the installer doesn’t link it and to make matters more confusing, the path is different depending on whether you installed it from Oracle or Apple. See Mac OS X 10.6.7 Java Path Current JDK confusing
I did the following to fix my environment
cd /System/Library/Frameworks/JavaVM.framework/Versions
sudo rm CurrentJDK
sudo ln -s /Library/Java/JavaVirtualMachines/<installed_jdk_version>.jdk/Contents CurrentJDK