Main Content

Java Runtime Environment Settings

In MATLAB®, you can configure the Java® heap size or specify the Java Runtime Environment (JRE™) path.

To access these settings, on the Home tab, in the Environment section, click Settings. Then select MATLAB > General > Java Runtime Environment.

Java Heap Size

You can adjust the amount of memory that MATLAB allocates for Java objects.

Note

The default heap size is sufficient for most cases. Increasing the heap size decreases the amount of memory available for storing data in arrays.

To adjust the heap size, in the Java Heap Size section:

  1. Specify a value using the slider or spinner.

  2. Click OK.

  3. Restart MATLAB.

If the amount of memory you specified is not available upon restart, then MATLAB resets the value to the default and displays an error dialog box. To readjust the value, repeat the previous steps.

If increasing the heap size does not eliminate memory errors, then check your Java code for memory leaks. Eliminate references to objects that you no longer need.

Java Runtime Environment Path

Since R2025a

To set the path to the JRE, in the Java Runtime Environment Path section:

  1. Select one of the version options. For more information about these options, see the jenv version argument.

  2. Click OK.

  3. Restart MATLAB.

See Also

Functions

Topics