Installing Matlab R2013 8.01 on Linux Headless Xvfb using lightdm and fluxbox

Good, you are a Matlab user like me, but.. why are you willing to install it on a headless linux workstation ? I thought i was the only person in the world doing that but you reading this proves i am not alone…

1) Well you mounted the iso image:

mount -o loop Matlab801_MacUnix.iso /mnt/cd

2) And tried to install but…. you are getting this

java.lang.InternalError: Can't connect to X11 window server using ':20.0' as the value of the DISPLAY variable.
        at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
        at sun.awt.X11GraphicsEnvironment.access$100(Unknown Source)
        at sun.awt.X11GraphicsEnvironment$ Source)
        at Method)
        at sun.awt.X11GraphicsEnvironment.(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)

3) OPS! this should not be difficult you think…

#Try this...
install_linux -mode silent
#And this... 
install_linux -javahome /opt/java -mode silent
#And your DISPLAY variable is logically correct! because ...
printenv | grep DISPLAY

The error message keeps displaying:

Error: The application encountered an unexpected error and needs to close.  You may want to try re-installing your product(s).  More information can be found at /tmp/mathworks_root.log

And you are able to run any other X application, starting from xclock… but the Matlab install do not wants to start.
Do not worry, it is not all lost.
First, you will have to modify the install_linux shell script, but the image is readonly, so you will have to do a trick:
4) First create a directory

mkdir /mnt/tmpcd
cd /mnt/tmpcd

5) Copy there the install_linux script

cp /mnt/cd install_linux /mnt/tmpcd

6) Modify this line:

java_cmd="$java_exe -Xmx512m $XTRAFLAGS -Djava.ext.dirs=$JAR_SEARCH_PATH $JAVA_LAUNCH_TARGET -root \"$ROOT\" -tmpdir \"$TEMP_DIR\" -inputFile '$ROOT/install_ini_linux.txt' $arglist"
#And add this: "-Djava.awt.headless=true" It should look like this:
java_cmd="$java_exe -Xmx512m $XTRAFLAGS -Djava.awt.headless=true -Djava.ext.dirs=$JAR_SEARCH_PATH $JAVA_LAUNCH_TARGET -root \"$ROOT\" -tmpdir \"$TEMP_DIR\" -inputFile '$ROOT/install_ini_linux.txt' $arglist"

7) Now create a link to all the other files, i did it like this

# Being in /mnt/tmpcd
for i in /mnt/cd/*; do ln -s $i; done

8) Now you are ready! install it.

(Feb 23, 2016 15:36:37) Installing Product: Simulink Report Generator 3.14
(Feb 23, 2016 15:36:38) Installing Product: Simulink Verification and Validation 3.5
(Feb 23, 2016 15:36:38) Installing Product: Stateflow 8.1
(Feb 23, 2016 15:36:39) Installing Product: Statistics Toolbox 8.2
(Feb 23, 2016 15:36:40) Installing Product: Symbolic Math Toolbox 5.10
(Feb 23, 2016 15:36:57) Installing Product: System Identification Toolbox 8.2
(Feb 23, 2016 15:37:06) Installing Product: SystemTest 2.6.5
(Feb 23, 2016 15:37:09) Installing Product: Wavelet Toolbox 4.11
(Feb 23, 2016 15:37:26) Notes:
Your installation may require additional configuration steps.

1. The following products require a supported compiler:

MATLAB Compiler 4.18.1
MATLAB Builder JA 2.2.6
Stateflow 8.1
Simulink Coder 8.4
MATLAB Coder 2.4

2. Simulink requires a C compiler for simulation acceleration, model reference, and MATLAB Function Block capabilities. It is recommended that you install a supported compiler on your machine.

3. To accelerate computations with the following products, a supported compiler is required:

SimBiology 4.3
Fixed-Point Designer 4.0
(Feb 23, 2016 15:37:26) Exiting with status 0
(Feb 23, 2016 15:37:26) End - Successful.