MATLAB 2024a issues with Java version in Apple Silicon

Hello!

I am trying to figure out which versions of MATLAB and Java are compatible with my computer, which is a Macbook with the Apple M1 Pro chip (Apple Silicon). I was following Tutorial 2 on importing subject anatomy and came across this error when clicking "Save" on the MRI viewer after adding the fiduciary points:

As this post suggested, I changed the Java version from 11 to 8 using MATLAB's jenv. However, when I tried to restart MATLAB, the app would no longer open on my computer. It seems that other Mac users using the MATLAB 2024a/Java version 8 combination are having this issue as well - so I was wondering if there is another combination that would still be compatible with my computer.

Hi @minajung,

Thanks for the link to the MathWorks question, that shed some light on the cause and to find the solution which is below:

Solution
The solution is to install a JDK8 compatible with Apple Silicon, as indicated in this post at MathWorks:

Steps:

  1. Download Amazon-Correto-8 for Apple Silicon (architecture macOS aarch64) from here:
    Downloads for Amazon Corretto 8 - Amazon Corretto 8

  2. Install the it following the provided instructions:
    Amazon Corretto 8 Installation Instructions for macOS 11 or later - Amazon Corretto 8

  3. Start Matlab, and change the Java version that it uses with the command
    >> jenv('system')
    This command will try to find Java8 installed in step 2.

  4. Restart Matlab

  5. Verify that Matlab is using Java 8 with the command:
    >> version -java
    which should return:
    Java 1.8.0_412-b08 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode

At this point you should be able to run Brainstorm and its functions without further issues.

I downloaded Amazon-Corretto-8 and followed the instructions, but the MATLAB app still will not open. I tried installing MATLAB2023b to see if that was the issue, but the same thing happened - only when I use jenv to set both versions to Amazon-Corretto-11 will the app open on my computer.

Hi @minajung, could it be the case that you have installed two versions of Java8? The download from the Oracle website, and the download from the Amazon

Do you mean using the matlab_jenv command in the terminal, or the command jenv in Matlab?

Adding @chinmay.chinara to this post

Hi @minajung,

Let me break it down the way I did it and let me know if it works for you :

  1. Download Amazon-Correto-8 from Downloads for Amazon Corretto 8 - Amazon Corretto 8 (this package: https://corretto.aws/downloads/latest/amazon-corretto-8-aarch64-macos-jdk.pkg).
  2. Install the package based on the steps here: Amazon Corretto 8 Installation Instructions for macOS 11 or later - Amazon Corretto 8 and JDK 8 should be installed in the location /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/
  3. Open MATLAB (any of the Apple Silicon versions)
  4. run version -java in the MATLAB command window verify that it gives Java 11.0.23+9-LTS with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode
  5. In the MATLAB command window: run jenv('/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/jre') to change to Amazon-correto-8.
  6. Restart MATLAB.
  7. running version -java now should give Java 1.8.0_412-b08 with Amazon.com Inc. OpenJDK 64-Bit Server VM mixed mode

After this start Brainstorm and run the Tutorial and everything should work fine.

I think the issue was I installed the wrong version of Amazon Corretto 8 - it is opening now. The subject anatomy error is also not appearing. Thank you for your help!

1 Like