Tonight I tried to run a program that I'd written a few weeks ago. As soon as it started up, it crashed MATLAB, to the point where MATLAB was no longer running. Let's call the program "slides.m". I restarted MATLAB, typed "slides," pressed return, and it crashed again. Hmmm.

So I copied the first line of the program into the command window. It's a variable assignment, and it worked. The next program line was similar, and it also worked. So I copied the third line to the command line, and pressed return. MATLAB quit immediately. The line that caused the problem? It is "figure(1)"!

I next looked at the console:

7/26/11 8:01:03 PM [0x0-0x12e12e].StartMATLAB[4861] [1] 4887

7/26/11 8:01:35 PM [0x0-0x12e12e].StartMATLAB _NSJVMLoadLibrary: NSAddLibrary failed for /libjawt.dylib

7/26/11 8:01:35 PM [0x0-0x12e12e].StartMATLAB JavaVM FATAL: lookup of function JAWT_GetAWT failed. Exit

I did update the system recently. I hope that's not the source of the problem, but I'm suspicious. It failed to find "JAWT_GetAWT"? That's pretty odd.

I don't see any MATLAB crash logs under my directory. I would look here for more information if they were there.

So I did an on-line search, "MATLAB crash JAWT_GetAWT," and the first search result is "Crash after OS X 10.6.8 update - Newsreader - MATLAB Central." At least I know other people have this problem.

So there is a problem with a recent Mac update to Java that affects MATLAB, where MATLAB crashes on any graphics calls. I found a solution at http://www.mathworks.com/matlabcentral/newsreader/view_thread/309912 about 2/3rds down the page (Message: 42). (In case that thread becomes deleted, what fixed it for me was to add this line to .cshrc: export DYLD_LIBRARY_PATH=/System/Library/Frameworks/JavaVM.framework/Libraries).

As far as I know, this only applies to Macs, and only if they have updated Java this summer.