Main Content

Configure Your System to Use Java

To call Java® library functionality from MATLAB®, you must have a supported version of the Java Runtime Environment (JRE™) software installed on your system. For supported version information, see MATLAB Interfaces to Other Languages.

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

Oracle Java Configuration

When you install MATLAB, MATLAB is configured to use Oracle® version 8 JVM®. If you prefer to use a different JRE, follow the instructions in OpenJDK Java Configuration.

MATLAB is supported on Mac computers with Apple silicon. For more information, see MATLAB on Apple Silicon Macs. (since R2023b)

OpenJDK Java Configuration

MATLAB supports OpenJDK® Java. For information about Java versions compatible with MATLAB, see MATLAB Interfaces to Other Languages. To use the OpenJDK JDK™ or JRE:

  1. Download and install a supported version of OpenJDK Java from https://adoptium.net/.

  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.

    jenv

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

See Also

|

External Websites