MATLAB: Do I get an error that MATLAB cannot locate the JRE upon startup for a 64 bit Linux machine

MATLAB

When I start MATLAB on my 64 bit Linux machine, I get the following error:
 
—————————————————————————
Warning: Cannot locate Java Runtime Environment (JRE) . . .
1. Either a correct JRE was not available for redistribution when
this release was shipped, in which case you should refer to the
Release Notes for additional information about how to get it.
2. Or you have tried to use the MATLAB_JAVA environment variable
to specify an alternate JRE, but MATLAB cannot find it. Please
run 'matlab -n' to determine what value you are using for
MATLAB_JAVA and fix accordingly.
---------------------------------------------------------------------------

Best Answer

This error indicates that you have installed the 32 bit version of MATLAB on a 64 bit machine. Generally this occurs when installing from downloads as the installer on the DVD will automatically install the correct version based upon the correct architecture for the OS.
To resolve this error you will either need to install the 64 bit version of MATLAB (glnxa64) or run MATLAB with the -glnx86 flag. Running a 32 bit version of MATLAB on a 64 bit machine is not supported. It is recommended to reinstall the correct version for your operating system. This can be done by running the installer from the DVD or by downloading the appropriate architecture files from MathWorks website. If downloading from the website, be sure to download all files (.common and .glnxa64) for each product and move them into the same directory as the installer. For more information on the files, see the related solution below.
If you need to run 32 bit MATLAB on a 64 bit machine, it must be launched with the -glnx86 flag:
matlab -glnx86
This issue can also occur sometimes for 64-bit MATLAB installation as well on Fedora Linux when the MATLAB_JAVA environment variable is not pointing to right location of Java. In this case either point it to the right location like:
 
$MATLABROOT/sys/java/jre/glnxa64/jre1.5.0/lib
or else remove this environment variable itself.