Main Content

Configure Your System to Use Java

R2026b

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.

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. If the JRE has been loaded, restart MATLAB. To verify, check if the JavaEnvironment Status property is set to loaded:

    jenv
    ans = 
    
      JavaEnvironment with properties:
    
              Version: "Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode"
                 Home: "C:\Program Files\MATLAB\R2026a\sys\java\jre\win64\jre"
              Library: "C:\Program Files\MATLAB\R2026a\sys\java\jre\win64\jre\bin\server\jvm.dll"
               Status: loaded
        Configuration: "factory"
  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.

See Also

|

Topics

External Websites