MATLAB: Do I receive an error dialog referring to CLASSPATH problems when trying to start MATLAB

classpathinstallationjavaMATLAB

I receive the following error dialog when trying to start MATLAB:
Check MATLAB installation. Possible JAVA classpath problem.
The Title of the dialog reads
Java initialization failed.
This error usually comes after a P4 JVM update. MATLAB itself may or may not start after this and if it does it will start in nojvm mode.

Best Answer

The problem may be caused by the way the MATLAB_JAVA environment variable is defined. To fix this problem, define the MATLAB_JAVA environment variable so that it points to the rt.jar file under your Java installation.
Here are the steps needed for making the change on the Windows platform:
For Windows NT/2000/XP:
*****************************
1. Click on Settings in the Start Menu
2. Choose Control Panel
3. Double click on System
4. Choose the Environment tab.
In here you can set the MATLAB_JAVA environment variable to the path of your JVM.
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=D:\jre
For example, replace "D:\jre" with the directory in which your JRE is installed. Make sure not to have any unnecessary spaces when specifying this environment variable.
For UNIX/Linux:
*****************
Use the SETENV command to set the MATLAB_JAVA environment variable. For example,
setenv MATLAB_JAVA <path to JVM>
There are two ways to have a JVM installed: a JRE (the runtime), or a JDK (the runtime plus a development environment). The MATLAB_JAVA variable should point to the root of the RUNTIME, which may actually be in a subdirectory of the full-blown JDK. Here's how to figure that out, along with some examples:
Find the file named rt.jar under your Java installation. (If that file doesn't exist, look for classes.zip). The directory that contains the directory that contains that file is the one that you need. For example,
On Windows:
**************
If the JDK is installed in D:\jdk1.2.1, the rt.jar file in that installation is D:\jdk1.2.1\jre\lib\rt.jar. So, the directory that contains the rt.jar file is D:\jdk1.2.1\jre\lib, and the directory that contains that directory is D:\jdk1.2.1\jre. So, the MATLAB_JAVA variable should point to D:\jdk1.2.1\jre.
On the other hand, if the JRE is installed in D:\jre1.3, the rt.jar in that installation is D:\jre1.3\lib\rt.jar. So, again, the directory is D:\jre1.3\lib, and the directory that contains THAT one is D:\jre1.3\, so you should set D:\jre1.3 as the value of MATLAB_JAVA.
On Unix:
********
If the JDE is installed in /usr/openv/java/jre/lib, the rt.jar in that installation is /usr/openv/java/jre/lib/rt.jar. So the directory that contains the file is /usr/openv/java/jre/lib, and the directory that contains that directory is /usr/openv/java/jre. This means the MATLAB_JAVA variable should point to /usr/openv/java/jre.
If you continue to encounter difficulties, perform the following steps:
1. Run the stand alone editor (meditor.exe) to see if Java in general is working.
2. Search under the MATLAB root directory to find javai.dll
If this file is not located in:
$MATLAB/sys/java/jre/win32/jre/bin
then the installation of the new JRE may not have taken place correctly. Perform the installation steps again. For instructions on how to install the JRE, see the following Related Solution listed below:
3. Look for the rt.jar file, which should be in:
$MATLAB/sys/java/jre/win32/jre/lib
If the stand-alone editor does not work, then the JRE did not install properly and needs to be re-installed.
You may also wish to review the compatability issues with using a Pentium IV Processor, described in the Related Solution below: