Main Content

jenv

Set JRE Java Runtime Environment path for MATLAB

    Description

    example

    jenv version sets the JRE™ path to use the default version on your system or to use the version shipped with MATLAB®. You must restart MATLAB to use the updated path.

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

    example

    jenv jrePath sets the path to a specific folder.

    example

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

    Examples

    collapse all

    jenv factory
    

    Restart MATLAB.

    Verify the version.

    version -java

    Use the version of the JRE installed at C:\Program Files\Java\jre8.

    jenv("C:\Program Files\Java\jre1.8.0_202")
    

    Restart MATLAB.

    Verify the version.

    version -java

    If you have administrator privileges, you can specify the JRE used by all users.

    Start MATLAB with administrator privileges.

    jenv -allusers system
    

    Restart MATLAB.

    Verify the version.

    version -java

    Input Arguments

    collapse 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: 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