Although MATLAB ships with a version of the JRE, MATLAB, users can replace it with a different version.
Step 1: Install and setup your version of the Java JRE
For step-by-step instructions, select the link below that corresponds to your OS.
Note: Starting with R2021b, MATLAB users can call matlab_jenv to specify a custom JRE location.
Step 2: remove the Java JRE that is shipped with MATLAB
Delete the folder containing the JRE and the outdated MSVC library. MATLAB’s version of the shipped JRE is located in matlabroot/sys/java/jre, where the value of matlabroot for your installation can be determined with this MATLAB command
Delete the folder matlabroot/sys/java/jre.