MATLAB Answers

How do I change the Java Virtual Machine (JVM) that MATLAB is using on Windows?

862 views (last 30 days)
I would like to use a different version of JVM than the default used in MATLAB on Windows.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 28 May 2019
Edited: MathWorks Support Team on 28 May 2019
MATLAB ships with one specific version of the JVM software on Windows depending on the release. MATLAB is fully supported only on these shipped versions of the JVM software. Some components might not work properly under a different version of the JVM software. For example, calling functions in a dynamically linked library that was created with a different JVM software version than that used by MATLAB might cause a segmentation violation error message.
If you choose to change the JVM software version used by MATLAB, you must:
1. Download and install the desired version of the JRE (Java Runtime Environment) or the JDK (Java Development Kit). The latter contains the JRE and development tools.
2. Determine the path of the JRE directory within that installation. This varies by platform and whether you downloaded the JRE or JDK (see below).
3. Set the MATLAB_JAVA environment variable to this path (see below).
4. Start MATLAB while that environment variable is set (see below).
Setting MATLAB to use new Java
Make sure you download the 32 or 64-bit version of the JDK or JRE, depending on your platform. To determine which platform you have, you can issue the following in MATLAB:
>> computer(arch)
The JRE is at the parent directory of the directory that contains the file "rt.jar". For example, if "rt.jar" is at:
C:\Program Files\Java\jre6\lib\rt.jar
you should set the MATLAB_JAVA environment variable to:
C:\Program Files\Java\jre6
1. Click Start
2. Right click Computer and choose Properties
3. Click Advanced System Settings and then click the Environment Variables button.
4. In the system variables section, set (or add) the MATLAB_JAVA system environment variable to the JRE path determined above
This change takes effect on the next launch of MATLAB from an icon, or from a subsequently opened command prompt window.
Verifying the Installation
To verify that MATLAB is using the correct version of the JVM software, type the following at the MATLAB prompt:
>> version -java
If MATLAB is not using your value of MATLAB_JAVA, you may need to logout and log back in again.
Other OS:
To change the JVM MATLAB uses for other systems, use the following links.
Mac OS:


Show 1 older comment
Greg Lyons
Greg Lyons on 25 Nov 2017
This procedure no longer works as of Java 9, as rt.jar has been removed: Java Platform, Standard Edition Oracle JDK 9 Migration Guide.
I have always been mildly concerned from a security standpoint that MathWorks ships an older JRE with Matlab. I hope MathWorks addresses this concern in future releases.
Yu Ang Tan
Yu Ang Tan on 27 Feb 2018
Is there no way to choose the newer JVM?
I tried setting MATLAB_JAVA to the path 'C:\Program Files\Java\jre-9.0.4' but I get this error: 'Unable to start JVM because of an invalid Java option'.

Sign in to comment.

More Answers (4)

Michael on 20 Apr 2017
I'm getting this error-message after setting up the new Java-Version:
Warning: An error occurred while reading the desktop configuration file. Using the default configuration. The desktop configuration was not saved successfully
Any suggestions about a fix?


Helder Oliveira
Helder Oliveira on 3 May 2017
After set up the MATLAB's java to version jre1.8.0_121, I'm getting the same as Michael. Any solution about this?
Nicolas Harmand
Nicolas Harmand on 19 Dec 2017
I have the same and Matlab still display the correct new version for java when asked : version -java Unfortunately, I still can't do what I was supposed to do with java 8 running on Matlab : make Matlab and ImageJ communicate correctly.
hp on 9 Nov 2018
version -java
ans =
Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ 64-Bit Server VM mixed mode the above version i have...and how to make guide to work...

Sign in to comment.

mohammadreza vali
mohammadreza vali on 13 Oct 2015
Edited: Walter Roberson on 13 Oct 2015
plaese help
my windows is 8.1 32 bit
matlab 2011 in my pc is good
but in matlab 2015 after click F1, it shows
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Could not initialize class$InstalledState
at com.mathworks.mde.cmdwin.CmdWinEditorKit$HelpAction.actionPerformed(
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at com.mathworks.mde.cmdwin.XCmdWndView.processKeyEvent(
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at com.mathworks.mde.cmdwin.XCmdWndView.processEvent(
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$ Source)
at java.awt.EventQueue$ Source)
at Method)
at$1.doIntersectionPrivilege(Unknown Source)
at$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$ Source)
at java.awt.EventQueue$ Source)
at Method)
at$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)
plaese help me


Sign in to comment.

Kapil Nagwanshi
Kapil Nagwanshi on 6 Mar 2018
Very Simple Solution!! Go to your jre folder C:\Program Files\Java\jre1.8.0_161 copy the content jre folder C:\Program Files\Java\jre1.8.0_161 paste it to 'C:\Program Files\MATLAB\R201XX\sys\java\jre' folder now it's ready to run with updated version


Show 2 older comments
Tiasa Ghosh
Tiasa Ghosh on 9 May 2018
After following this step, the error message changed to Unable to start the JVM because of an invalid Java option
Walter Roberson
Walter Roberson on 9 Jul 2019
Desla Sari which operating system are you using? The methods for Mac are quite different than for Windows.

Sign in to comment.

Ivan Carrasco
Ivan Carrasco on 20 Aug 2019
Edited: Ivan Carrasco on 20 Aug 2019
C:\Program Files\MATLAB\R2017b\sys\java\jre\win64\jre
Environment Variables


Sign in to comment.


No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by