MATLAB Runtime JRE setting
MATLAB Runtime also has a JRE setting and its value can be changed by running the "matlab_jenv -allusers <version>" command from <runtime root>\bin. Note, please make sure you are executing the command from <runtime root>\bin. Otherwise, if you have both MATLAB and MATLAB Runtime installed on one machine, you are changing MATLAB JRE setting instead of Runtime JRE setting if you execute the command directly. Because the matlab_jenv command under <MATLAB root>\bin will be executed without the folder specification.
Executing <runtimeroot>\bin\matlab_jenv without -allusers flag may not issue errors but is not effective to anything.
Deployed application JRE setting
When compiling a deployed application, the application's JRE setting depends on how JRE was set for the current MATLAB session:
- JRE setting sets with "-allusers" flag doesn't get included in the deployed application.
- JRE settings sets without "-allusers" flag
- R23b and higher: the setting gets removed if it is non-factory value. A warning is issued during mcc compile time . For example, if jenv is set to a custom path, you will see warning
"Your personal MATLAB preferences are set to use a version of Java installed on this system at <path>. This preference setting has been removed."
- R23a and lower: The setting value from the MATLAB session that compiles the app will be included in the deployed app. During compiling time, mcc warns you about the non-factory JRE setting.
Warning: Your MATLAB preferences are set to use a version of Java installed on this system at <path>. Users of this application may not have the same version of Java installed on their system causing the application to fail.
What JRE setting is my deployed application running with?
- If the deployed application has a JRE setting included as described in above section, it will run against this setting.
- R2023b or higher releases deployed application JRE sets to "factory": application run against factory JRE setting
- R2023a or lower releases, deployed application JRE sets to:
- a custom JRE path: The same JRE must be installed in the same directory on the target machine. Otherwise the app will fail and errors "Unable to find Java library", "Java Runtime Not Found" or "Failed to initialize Java". To get rid of this error,
- install the same custom JRE in the same directory on the target machine as on the MATLAB Developer's machine.
- Or on the MATLAB Developer's machine, set JER setting to "system" or "factory" and recompile the application.
- "system": system JRE setting on the target machine, which may not be the same system value on the developer's machine.
- "factory": factory JRE setting.
- If the deployed application doesn't have a JRE setting included, it will run against the MATLAB Runtime JRE setting, which could be factory or whatever has been set with <runtime root>\bin\matlab_jenv.