MATLAB: Do I get an “undefined function” error and loss of command functionality when I start MATLAB

desktopgenerateMATLABmatlabrcpathregenraterestoredefaultpathusejava

I receive the following error when starting MATLAB:
??? Undefined function or variable 'usejava'.
Error in ==> /matlab/toolbox/local/matlabrc.m
On line 24 ==> if usejava('Desktop')
After that, when I try to use any MATLAB commands, I receive further errors.

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This issue is due to a corrupt pathdef.m file, which contains a list of the directories in the MATLAB search path.
To resolve this issue, see the following:
If you are using MATLAB 7.0 (R14), type the following commands:
restoredefaultpath ; matlabrc
If this command resolves the issue, type the following command to save the current path for all future sessions of MATLAB:
savepath
If you are using versions of MATLAB prior to MATLAB 7.0 (R14), follow the appropriate instructions below:
For Windows Installations
Start MATLAB, and enter the following commands:
matlabpath(char(com.mathworks.jmi.MatlabPath.getDefaultPath))
path2rc(fullfile(matlabroot,'toolbox','local','pathdef.m'))
This will regenerate your pathdef.m file.
If you still have problems, send a copy of your pathdef.m file from $MATLAB/toolbox/local/ to support@mathworks.com and mention Solution 1-1AVEG in the subject field.