Main Content

Configure Your System to Use Java

MATLAB® provides two-way integration with the Java® programming language and supports specific OpenJDK® long-term support (LTS) releases across all platforms. You can configure your system to enable calling Java library functionality from MATLAB. To use Java in MATLAB, you must have a supported version of the Java Runtime Environment (JRE™) software installed on your system.

When you install MATLAB on Windows® or Linux® platforms, MATLAB includes Oracle® version 8 JVM®. However, for Mac computers with Apple silicon, you must download and use OpenJDK instead. For more information, see MATLAB on Apple Silicon Macs. Regardless of the operating system, you can choose to install and configure either the MATLAB Support for OpenJDK add-on or any supported OpenJDK version.

To find out what Java version MATLAB currently uses on your system, call the jenv function.

Install and Configure OpenJDK using MATLAB Add-On

After installing MATLAB, you can install the OpenJDK add-on using the Add-Ons Explorer:

  1. On the MATLAB Home tab, in the Environment section, click Add-Ons.

  2. In the Add-On Explorer, search for OpenJDK.

  3. Install the MATLAB Support for OpenJDK add-on.

  4. In the MATLAB Command Window, clear the current JRE so that MATLAB uses the installed OpenJDK add-on.

    jenv -clear

For more information, see Get and Manage Add-Ons.

Install and Configure Specific Version of OpenJDK

If you want to install a specific supported version of either OpenJDK JDK™ or JRE, you can get the software from adoptium.net:

  1. Download and install a supported version of OpenJDK Java from https://adoptium.net/. For version information, see Versions of OpenJDK Compatible with MATLAB by Release.

  2. If OpenJDK is the first Java entry on your system path, then configure MATLAB with this command.

    jenv("system")

    If OpenJDK is not the first entry and is installed in folder JRE_path, then configure MATLAB with this command.

    jenv("JRE_path")
  3. Restart MATLAB.

  4. Verify the version of Java that MATLAB is configured to use.

    version -java

Alternatively, call matlab_jenv from the operating system prompt to change the MATLAB configuration.

Use Oracle JVM Version 8

When you install MATLAB on Windows or Linux platforms, MATLAB is configured to use Oracle version 8 JVM.

See Also

|

Topics

External Websites