Contenido principal

Java Configuration for MATLAB Job Scheduler

R2026b
Since R2026b

MATLAB® Job Scheduler requires a Java® Runtime Environment (JRE™) to start and run scheduler processes. MATLAB Parallel Server™ does not include a JRE as part of its installation. If a compatible JRE is installed on the cluster node, then MATLAB Job Scheduler uses that JRE. Otherwise, MATLAB Job Scheduler automatically downloads and installs a compatible JRE. For information about Java versions compatible with MATLAB Job Scheduler, see MATLAB Interfaces to Other Languages.

How MATLAB Job Scheduler Selects a JRE

When you start MATLAB Job Scheduler processes by using control scripts at the command line or by opening Admin Center, MATLAB Job Scheduler selects a JRE, using the following order of preference:

  1. The path specified by the MJS_JAVA parameter in the mjs_def file.

    If you set the MJS_JAVA parameter in the mjs_def file, then:

    • If the specified path contains a compatible JRE, MATLAB Job Scheduler uses that JRE.

    • If the specified path exists but does not contain a compatible JRE, MATLAB Job Scheduler returns an error.

    • If the specified path does not exist, MATLAB Job Scheduler searches for a JRE on the cluster node.

    To specify your own JRE installation using the MJS_JAVA parameter, see Specify a Java Runtime Environment.

  2. The location of a compatible JRE that MATLAB Job Scheduler detects on the cluster node.

    MATLAB Job Scheduler searches the cluster node for a JRE. If MATLAB Job Scheduler finds a compatible version, it uses that JRE.

  3. An automatically downloaded JRE.

    If MATLAB Job Scheduler does not find a compatible JRE, then it uses MATLAB Package Manager (mpm) to download and install the MATLAB Support for OpenJDK® add-on from mathworks.com. MATLAB Job Scheduler then uses the JRE from the OpenJDK installation. This download requires an internet connection.

    If you set the MJS_JAVA parameter, then OpenJDK is installed at the specified path.

    If you do not set the MJS_JAVA parameter, then OpenJDK is installed in one of these locations, depending on your operating system:

    • Linux®: /usr/local/share/matlab/mjs/java

    • Windows®: %PROGRAMDATA%\matlab\mjs\java, where %PROGRAMDATA% is the system program data environment variable.

Before R2026b: By default, MATLAB Job Scheduler processes uses the JRE included with MATLAB Parallel Server. To use your own Java installation for the MATLAB Job Scheduler processes, use the MJS_JAVA parameter to specify a path to an installed JRE.

Specify a Java Runtime Environment

To specify a JRE installation for MATLAB Job Scheduler to use, follow these steps to set the MJS_JAVA parameter in the mjs_def file.

If an existing MATLAB Job Scheduler is running on your cluster, then before you make changes to the mjs_def file, you must stop the mjs service and job manager or worker processes running on each of the cluster nodes. For instructions, see:

Repeat these steps for each cluster node.

  1. Locate the mjs_def file on the cluster node. You can find this file in one of these folders. Replace matlabroot with the name of the folder where you installed MATLAB Parallel Server.

    • Linux: matlabroot/toolbox/parallel/bin/mjs_def.sh

    • Windows: matlabroot\toolbox\parallel\bin\mjs_def.bat

    To learn more about the parameters in the mjs_def file, see Define MATLAB Job Scheduler Startup Parameters.

  2. In the mjs_def file, set the MJS_JAVA parameter to the location of the JRE installation.

    On Linux operating systems, enclose the path in quotes.

    MJS_JAVA="/usr/lib/jvm/java-11-openjdk"

    On Windows operating systems, do not enclose the path in quotes.

    set MJS_JAVA=C:\Program Files\Java\jdk-11\jre

After updating the mjs_def file on all your cluster nodes, start the mjs service and job manager or worker processes on the cluster nodes.

Configure Java for MATLAB Workers

To run MATLAB code that depends on Java libraries, MATLAB Parallel Server workers require a JRE. After you install MATLAB Parallel Server on your cluster nodes, you can configure workers to use any compatible JRE.

If the cluster nodes already have a JRE installed for MATLAB Job Scheduler processes, and the JRE is compatible with MATLAB Parallel Server workers, then you can use the same JRE installation for both.

For instructions, see Configure MATLAB Parallel Server Workers to Use Java.

See Also

Topics

External Websites