NOTE: This guide is written for Ubuntu Hardy with Compiz enabled and Sun Java version 1.0.6_06 installed. I did not devise all of the techniques employed in this guide but have made my best efforts to acknowledge those who did.
Ensure that you have the current Sun Java release installed (currently version 6). You can check this by opening a terminal (Applications-> Accessories->Terminal) and typing the following:
Which, assuming you have the current version installed, should output something like this:
If you receive the above output, things should be in order to start the installation and you can move on to the next section. Unfortunately, properly installing Java is beyond the scope of this guide; for instructions on how to install Java you will have to search the forums.
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)
NOTE: It is important that you have the Java version 6 or newer installed for this guide to be useful, some of the code will NOT work with version 5 and could keep Matlab's window contents from being shown. The following workaround for running applications with Java version 5 and Compiz does NOT work for version 6:
Basic Matlab Installation
Now for the actual installation of Matlab, be sure you have the Matlab installation media intended for UNIX. First insert the Matlab DVD into your computer, the DVD should be automatically mounted. Open the terminal (Applications-> Accessories->Terminal) and navigate to the root directory of the DVD. This can be accomplished on most computers by typing the following:
You can verify that you are in fact currently in the DVD's root directory by typing the following:
Which will list all of the files and folders in the current directory. For the Matlab R2008a DVD, ls outputs the following:
Now the DVD is mounted and you are in its root directory. The install script needs superuser privileges in order to copy files to certain parts of the filesystem. In order to run the install script with elevated privileges, type the following into the terminal:
install inst_doc.pdf mac_install_guide.pdf update
InstallForMacOSX.app license.txt readme.txt utils
This will start the installer; you will be prompted for your preferred method of installation and for the "Matlab root directory location." This is where Matlab will be installed, the Matlab installation guide recommends you install Matlab to /usr/local/matlabR2008a and warns you not to install in the same directory as a previous release, but the choice is yours. Once you have chosen a installation directory, a progress bar signifies the beginning of the actual copying of files. Once it's finished you will be prompted to locate a license file which concludes the installation. Admittedly, there is nothing groundbreaking here, the more useful stuff comes in the next section.
Coaxing Matlab Into Running
This section is really the reason I set out to write this How To, hopefully it will be useful to someone. The two main problems which I ran into when I first installed Matlab are listed below.
Matlab doesn't start, the splash screen comes up but Matlab never actually runs. I do not know why this problem occurs but the solution was posted on another thread, you can find it here. It comes from karel.007 and is as follows:
Where $MATLAB is the directory you specified in the installation above, you may need to have superuser privileges to accomplish this for files not in your home directory. Running the command with superuser privileges would look like the following:
mv $MATLAB/sys/java/jre/glnxa64/jre1.5.0/lib/amd64/motif21/ $MATLAB/sys/java/jre/glnxa64/jre1.5.0/lib/amd64/motif12
sudo mv $MATLAB/sys/java/jre/glnxa64/jre1.5.0/lib/amd64/motif21/ $MATLAB/sys/java/jre/glnxa64/jre1.5.0/lib/amd64/motif12
Matlab occasionally stops taking input form the keyboard. In my case this happened whenever the help window was opened. To solve this problem, we must undo the workaround for Java 5. The workaround gives the system variable AWT_TOOLKIT the value MToolkit. You can check to see what the current value is by entering the following:
More than likely the above command will output:
You can temporarily erase the value of the system varible by opening the terminal (Applications-> Accessories->Terminal) and typing the following:
If the above code opens Matlab and runs it to your satisfaction, you can make this change permanent by editing the script that starts Matlab. To do this, first open the terminal and navigate to Matlab's bin directory. You can do this with the following:
unset AWT_TOOLKIT & matlab
Again, $MATLAB is Matlab's root directory and should be replaced with the installation directory specified above. Once in the bin directory you need to open the matlab script which runs Matlab. You can do this with your favorite editor, in this case the code below opens it in gEdit for simplicity.
Once you have the matlab script open, add the following line just below the header ~line 181:
Your matlab script should look something like the following:
# Copyright 1984-2007 The MathWorks, Inc.
# $Revision: 22.214.171.124 $ $Date: 2007/11/12 22:52:38 $
# Enable proper operation on Windows when using a UNIX-compatible shell
In order to run Matlab from the GUI, you must use the -desktop parameter, making the command to run Matlab:
You should, hopefully, now have a completely functional Matlab installation!