This problem is caused by MatLab 2013b using it’s packaged and outdated Java. Instead we want it to use our current version, so we’ll have to point the environment variable MATLAB_JAVA to the correct version. This solution has worked on 10.9 Mavericks
Edit (2/18/2014): The old crossed-out procedure below doesn’t persist after a reboot. Although the command:
launchctl setenv MATLAB_JAVA "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
works, it is required after every reboot.
None of my efforts at adding the setenv command into launchd.conf, launchd-user.conf, or ~/.bashrc worked at ALL! I completely got fed up with this stupid system that wouldn’t let me set simple variables. The kicker? Even though launchctl setenv
works, simply typing in setenv
into the Terminal results in ‘command not found’ for bash.
So here’s a persistent workaround from Erik Johnson over at the Mathworks forums, it involves linking to the updated Java:
Open Up Terminal and do the following:
1. cd /Applications/MATLAB_R2013b.app/sys/java/jre/maci64/
2. mv jre jre.OLD
3. ln -s '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' jre
Done. Now I can move on with my life. Such a stupid, stupid problem.
1. Update Java to its current version, I believe I installed the Java 7 JRE.
2. Create a new file /etc/launchd.conf, to do this I type in the Terminal:
sudo nano /etc/launchd.conf
3a. If you have the JRE, put into the file:
setenv MATLAB_JAVA "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
3b. If you have the full JDK, put into the file:
setenv MATLAB_JAVA "/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre"
(Note: your path could be slightly different, check to make sure)
4. Press Control + X
to save the file and quit nano.
5. Your issue should be fixed after a reboot, launchd.conf will make sure this change persists after rebooting. To see if it works without rebooting, type into the Terminal:
launchctl setenv MATLAB_JAVA "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home"
6. Launch MatLab to verify the issue is fixed.
Resources: http://www.mathworks.com/matlabcentral/answers/102946
Remarkable work, you solved my problem! Tons of thanks 🙂