MATLAB: Does MATLAB crash with the error: “problem determing the version of java installed”

MATLAB

When I try to open MATLAB on my Mac, it returns the error:
problem determing the version of java installed
Java Preferences show that Java is installed. "java -version" shows it there as well, but gives the warning:
dyld: shared cached was built against a different libSystem.dylib, ignoring cache
How do I get MATLAB to work?

Best Answer

From the Terminal, run the following:
sudo update_dyld_shared_cache -force
Afterwards, run this command again:
java -version
There should no longer be a warning, and MATLAB should work.