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

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

 Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 18 Nov 2026 à 0:00
Modifié(e) : MathWorks Support Team le 19 Nov 2026 à 14:27
In releases R2026a and earlier, Linux versions of MATLAB ship with the Oracle® version 8 Java Virtual Machine™ (JVM). However, you have the option to attempt to use other JVMs. 
If you choose to change the JVM software version used by MATLAB, follow the instructions below based on the release of MATLAB you are using. 

R2021b and newer

Please follow the instructions: Set Java path for MATLAB (jenv). If you don't have MATLAB installed and are only using the MATLAB Runtime, follow the instructions: Set the Java path for MATLAB from system prompt (matlab_jenv). 

 

Notes
  • MATLAB_JAVA takes higher precedence over jenv/matlab_jenv when both are set.
  • R2020a and newer: MATLAB supports OpenJDK Java 8.  
  • R2023a and newer: MATLAB also supports some newer versions of OpenJDK Java. See Versions of OpenJDK Compatible with MATLAB by Release for details. MATLAB is fully supported only for these specified versions of the JVM software. Some components may 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.
  • R2026a and newer: You can use the MATLAB Add-Ons manager to install a supported Open JDK version. In the Toolstrip at the top, select "Home", then "Add-Ons". In the "Add-Ons Explorer" search for "JDK". Select "MATLAB Support for Open JDK" and follow the instructions. This should configure MATLAB for the installed JRE, but you can use "jenv" or (outside MATLAB) "matlab_jenv" to check and configure the JRE, as indicated in the instructions below.
  • R2026b and newer: MATLAB does not require a Java runtime unless you are using Products or Features that have Java dependencies (e.g., Java Interface or Database Toolbox). 

R12 and newer

On csh or tcsh shells, use the "setenv" command to set the MATLAB_JAVA environment variable. For example:
setenv MATLAB_JAVA <JRE path>
This command needs to be run in every new shell window.

 

On the bash shell, execute:
export MATLAB_JAVA=<JRE path>
This setting will apply to MATLAB launched from that shell 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 Operating Systems/Platforms 
To change the JVM MATLAB uses for other systems, use the following links.

 

Windows
macOS

Plus de réponses (0)

Catégories

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by