Main Content

matlab_jenv

Set the Java path for MATLAB from system prompt

Since R2021b

Description

matlab_jenv version sets the Java® path to use the version included with MATLAB®, the default version on your system, or the version in a specified folder.

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.

example

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

matlab_jenv -help displays the syntax.

Examples

expand all

After installing MATLAB, a system administrator can set the Java 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

Java version, specified as "system" to use the default version on the system or "factory" to use the version included 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 — The function selects the supported Java version available on the Windows PATH or the registry. The Java might be Oracle® JRE™ or OpenJDK® JRE.

  • Linux® platforms — The function selects the supported Java version available on the system path. The Java might be Oracle or OpenJDK Java.

  • macOS platforms — The function selects the supported Java version based on one of these macOS java_home scripts:

    /usr/libexec/java_home -f -v 1.8
    /usr/libexec/java_home -f -v 1.11

Example: matlab_jenv system

Tips

Version History

Introduced in R2021b

expand all

See Also

Functions

Objects

External Websites