Monday, July 03, 2023

Optimize Java JVM for Matlab


Matlab UI has been very slow and buggy on MacOS due to the default JVM. A fast JVM can be used to fix this: 

1. Download and install Azul JDK 8
    NOTEJDK 11 would also work on latest version of Matlab. Newer version doesn't work with Matlab.

2. Set the new JVM to Matlab using matlab_jenv command:
/Applications/MATLAB_R2021b.app/bin/matlab_jenv /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/
    NOTE: can also run jenv command in Matlab to assign the path of new JVM.
    NOTE: for JDK 11, use /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/

3. Run Matlab and confirm the new JVM by 'version -java'

4. To reset to default JVM, use:
/Applications/MATLAB_R2021b.app/bin/matlab_jenv factory

No comments: