MATLAB: Do I receive a Fatal Error when starting MATLAB on Linux or Mac

MATLAB

When launching MATLAB from Terminal with -nodesktop, I receive the following errors on Startup:
Unable to initialize com.mathworks.mlwidgets.html.HTMLPrefs
Unable to initialize com.mathworks.vrd.matlab.LicenseActionsFactory
Fatal Error on startup: Failure loading desktop class
MATLAB starts only with -nojvm.
I would like to resolve this issue.

Best Answer

This issue generally occurs when MATLAB is directed to the wrong Java Runtime Environment during startup. This will occur if there is a classpath.txt located on the system's path (specified by the $PATH environment variable).
To resolve this issue, either remove the offending classpath.txt from the path, or add the $MATLABROOT/bin folder to your path.
For Mac, remove classpath.txt from your user's home directory. Your home directory can be located from the Finder's Go option in the Menu Bar on top of your screen.
For Linux, depending on the shell you are using, this latter solution can require different commands:
For bash shell:
export PATH=$PATH:[$MATLABROOT]/bin
For tcsh or csh:
set PATH = ($PATH [$MATLABROOT]/bin)
NOTE: In the above commands [$MATLABROOT] must be replaced with the correct location of the MATLAB root folder.
You can either enter these commands each time you login, or you can edit your .bashrc or .cshrc files (depending on whether you are using bash or tcsh/csh respectively) to add the command to the startup routine.
If you are unable to to resolve this issue by adding $MATLABROOT/bin to the PATH variable, try locating and removing any offensive classpath.txt files. If you are still unable to resolve this issue, contact Installation support here: