Configure Your System to Use Java
R2026bMATLAB® 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:
On the MATLAB Home tab, in the Environment section, click Add-Ons.
In the Add-On Explorer, search for
OpenJDK.Install the MATLAB Support for OpenJDK add-on.
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:
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.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")If the JRE has been loaded, restart MATLAB. To verify, check if the
JavaEnvironmentStatus property is set toloaded: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"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
- Versions of OpenJDK Compatible with MATLAB by Release
- MATLAB on Apple Silicon Macs
- MATLAB Interfaces to Other Languages