MATLAB: Do I receive the errors “Failure Loading Desktop Class” or “Desktop Launch Failed” when I attempt to start MATLAB 6.5 (R13) or later

MATLAB

I receive one or more of the following errors when I attempt to start MATLAB 6.5 (R13) or later:
Failure Loading Desktop Class
Desktop Launch Failed
Java exception occurred:
java.lang.NullPointerException
at com.mathwords.ide.desktop.Desktop.<init>[Desktop.java:487]
at com.mathwords.ide.desktop.MLDesktop.<init>[MLDesktop.java:607]
at com.mathwords.ide.desktop.MLDesktop.<init>[MLDesktop.java:600]

Best Answer

The first step is to try starting MATLAB directly from the bin or bin/$arch folder in your MATLAB installation directory. If the issue persists, then generally this is due to a corrupt or incompatible Java Virtual Machine (JVM). Some of our customers have found that installing an alternate JVM fixes this problem. To get the latest JVM made by Sun Microsystems go to:
NOTE: MATLAB has only been tested on the JVM that we ship with MATLAB. There are components of MATLAB that may not work properly under a different version of the JVM.
(For MATLAB R13 we recommend version 1.3.1. For R14, use 1.4.2. For R2006a through R2007a use 1.5.0. For R2007b and above, use 1.6.0)
In order to point MATLAB to the new JVM, you will need to set a "MATLAB_JAVA" environment variable to point to the path of the Java Runtime Environment (JRE) of your new JVM. First you will need to determine which path to set the variable to.
Determining which path to set MATLAB_JAVA
=====================================
The MATLAB_JAVA variable should point to the root of the JRE. To determine which directory this is follow the instructions below:
1) Locate your JRE installation directory. This directory should have 'lib' and 'bin' as subdirectories.
2) Search under 'lib' for a file named 'rt.jar' or 'classes.zip'.
3) If the JRE directory has 'lib' and 'lib' has either one of these files, you will set MATLAB_JAVA to this JRE directory.
Example:
If the JRE is installed in:
C:\Program Files\Java\jre1.5.0_07
and there is an lib directory:
C:\Program Files\Java\jre1.5.0_07\lib
and rt.jar (or classes.zip) exists in that directory, then the MATLAB_JAVA variable should point to:
C:\Program Files\Java\jre1.5.0_07
Setting MATLAB_JAVA
===================
Follow the instructions below to set the variable:
For Windows NT/2000/XP:
====================
1. Click on Settings in the Start Menu
2. Choose Control Panel
3. Double click on System
4. Choose "Environment Variable" (on the Advanced Tab).
5. Under "System Variables", click "New" and create a varible called "MATLAB_JAVA". The value of the variable will be the path listed above.
For Windows 95/98/ME:
===================
1. Open the AUTOEXEC.BAT file in your favorite text editor.
2. Add a line that reads
SET MATLAB_JAVA=<path to the JRE>
From the above example, this would be:
SET MATLAB_JAVA="C:\Program Files\Java\jre1.5.0_07"
NOTE: If the path contains any spaces, you will need to wrap the path in quotes (").
If the above fix does not work, follow the instructions below:
1. Delete MATLAB's persistent data files (matlab.prf & matlab.ini).
2. Start MATLAB with the -nodesktop flag.
3. Issue the "desktop" command within MATLAB.
4. Record any error messages from the command window and log a Service Request at:
indicating that you have looked at this solution already.
5. Follow the instructions in the Related Solution with your help request.