Main Content


Set JRE Java Runtime Environment path for MATLAB from system prompt


matlab_jenv version sets the JRE™ path to use the default version on your system or to use the version shipped with MATLAB®.

The matlab_jenv command does not start MATLAB. To use MATLAB, start MATLAB at the same system prompt where you set the path variable.

This command sets the path for all future MATLAB sessions but does not change the path for other applications on your computer.

matlab_jenv jrePath sets the path to a specific folder.


matlab_jenv -allusers ___ sets the path for all users, using any of the previous syntaxes.

matlab_jenv -help displays the syntax.


expand all

After installing MATLAB, a system administrator can set the JRE path for all users.

Use the system value for the installed MATLAB. With administrative privileges, at the operating system prompt, type:

matlab_jenv -allusers system

Verify the version. Start MATLAB and type:

version -java

Input Arguments

expand all

JRE version, specified as system to use the default version on the system or factory to use the version installed with MATLAB.

The function selects the default value for system based on platform. If the selected version is incompatible with MATLAB, then MATLAB starts without the ability to use Java® or any features that use Java. For information about Java versions compatible with MATLAB, see MATLAB Interfaces to Other Languages.

  • Windows® platforms—Selects the version 8 JRE available on the Windows PATH or the registry. The JRE might be Oracle® JRE or OpenJDK® 8 JRE.

  • Linux® platforms—Selects the version 8 JRE available on the system path. The JRE might be Oracle JRE or OpenJDK 8 JRE.

  • macOS platforms—Selects the version 8 JRE based on this macOS java_home script:

    /usr/libexec/java_home -f -v 1.8

Example: matlab_jenv system

JRE path, specified as a string or a character vector, where jrePath is a folder to an installed JRE this computer.

Example: C:\Custom\Java on Windows

Example: /usr/local/jre for OpenJDK 8 JRE on Linux and macOS

Version History

Introduced in R2021b

See Also