Matlab Change Java Version

We can get java used in Matlab by type “version -java” in Matlab command window. I have use Matlab R2013a, the java version in this Matlab version is :

>> version -java
ans =
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode

This is the output after I change the default Matlab java version :

>> version -java
ans =
Java 1.7.0_51-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

I have installed Java 1.7 in my computer. So, I want to use this new  java version compared with the Matlab default java version. Below are steps how to change Matlab java version.

Windows OS :

  • Open Windows Explorer
  • Right click at my computer, choose Properties
  • Select Advanced system settings
  • Select Advanced
  • Select Environment Variables
  • Click New at System variables
  • Fill Variable name with MATLAB_JAVA
  • Fill Variable value with your installed java directory. Example : in my windows, I fill this paramater with C:\Program Files\Java\jre7
  • Click OK
  • Open Matlab, type version  -java in Matlab command window
  • You will get the new java version in your current Matlab.

Linux OS :

  • Open file .bashrc in your home directory. Example : I use vim to edit this file using command :  vim   ~/.bashrc
  • create MATLAB_JAVA variable. Add this text in your .bashrc file :  export MATLAB_JAVA=your_java_path
  • Example : if you have installed your java in  /usr/local/java_dir, so MATLAB_JAVA=/usr/local/java_dir
  • logoff and login again. check your matlab java version with command : version  -java

Note :

If you have created a matlab GUI application (I am using matlab GUIDE) using the previous (original java version) and try to open that GUI application in new installed java version, you will get the different result. Some of button maybe missing. So, you need to recreate the GUI or return back java version to original.

Add a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.