Matlab does not find Java Runtime Environment (Mac Silicon)
Show older comments
Hello, I'm trying to install matlab in my computer (Macbook pro, M2). It requires a java runtime environment (JRE). It give as an option the one from Amazon, but I have a JRE installed directly from Java's website. After reading this article on how to change the JRE path from the command window, I run the following, from the hardrive location:
<path/to/matlab_jenv> <path/to/JRE>
I'm copy-pasting the JRE path from the java applet. Anyway, the error I'm getting is this:
"Unable to validate Java path: <path/to/JRE>".
Can anyone help? Thank you!!
8 Comments
Efren
on 29 Apr 2024
Plante jean-luc
on 1 May 2024
Hello
I have the same problem to configure the path of the JRE
In which matlab file (2023b) do you change the path
Thanks a lot for your answer!
Plante jean-luc
on 1 May 2024
Sorry , it is on a macbook pro M1
Murl Donley
on 18 May 2024
The answer did not work with the Oracle install of Java (1.8.0_411). However, after installing Amazon Corretto 11, following the instructions resulted in success.
Aditya
on 1 Aug 2024
Yes this is not working for my case too. I am getting
"Java version at "/Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home" not supported"
XING
on 3 Sep 2024
1,直接从java官网下载安装的jre,是没有办法支持matlab运行的。比如,最开始是找不到java的运行环境,按照贴主的提示操作后,不再提示运行环境错误,而变成了打开软件闪退(错误报告: MATLAB 在处理 Java 虚拟机(JVM)相关的任务时发生了错误。)
2,安装好Amazon Corretto 11后(https://ww2.mathworks.cn/support/requirements/apple-silicon.html),在终端执行:/Applications/MATLAB_R2024a.app/bin/maca64/matlab_jenv /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home。
能够正常运行了
Answers (2)
Hi,
I was having the same issue. I am using a Mac M3Pro which is also on the Apple Silicone.
First, get the location of your JAVA 11 runtime. I have multiple JDKs installed and managed the installation with SDKMAN.
Little installation guide for SDKMAN:
curl -s "https://get.sdkman.io" | bash
source "/Users/username/.sdkman/bin/sdkman-init.sh"
NB: SDKMAN additions are made to your .zshrc after installation. For SDKMAN to work THESE ADDITIONS NEED TO BE KEPT AT THE BOTTOM OF YOUR .ZSHRC!!
Once you found your desired java versions by running:
sdk list java
Run this to install your desired jdk:
sdk install java 11.0.23-amzn
You'll need to export it to your ~/.zshrc. Open up your ~/.zshrc with sudo nano ~/.zshrc and add this:
export MATLAB_JAVA=/Users/username/.sdkman/candidates/java/11.0.23-amzn
Update ~/.zshrc by running:
source ~/.zshrc
You can now run this command in your terminal to launch MATLAB by pointing it to your desired JDK (edit 20xx to match your MATLAB version. Mine was 2024b):
MATLAB_JAVA=$MATLAB_JAVA /Applications/MATLAB_R20xx.app/bin/matlab
4 Comments
Matei
on 30 Sep 2024
Thank you so much! This worked. The only downside is that you always have to open MATLAB using your last command in the terminal. You can create an automation to make the process simple.
Marius
on 30 Sep 2024
Nice one, glad to hear!
Yeah agreed, I created a shell script runMatlab.sh with this command inside.
You can follow this to make it work:
- open a terminal in your user directory
- mkdir matlabShortcut
- cd matlabShortcut
- touch runMatlab.sh
- nano runMatlab.sh
- insert this inside the file:
#!/bin/bash
MATLAB_JAVA=$MATLAB_JAVA /Applications/MATLAB_R2024b.app/bin/matlab
7. press Control+X, then press Y and Enter
8. in the terminal in the same location as your file run:
chmod +x runMatlab.sh
9. run ./runMatlab.sh
Matei
on 7 Oct 2024
I just found a way to make MATLAB open every single time from the app icon, without any type of script.
First you need to get access to MATLAB's Command Window, and from there, you can change the path to the JRE permanently using the following command:
>> jenv('/Users/username/.sdkman/candidates/java/11.0.23-amzn')
From now on, everytime you open the app, it will use the JRE found on the path you specified in the command above.
Vincent
on 11 Oct 2024
You are the GOAT
Travis Massey
on 25 Apr 2024
Edited: Walter Roberson
on 25 Apr 2024
0 votes
I ran into this same issue in Windows today. The problem was that I had downloaded 32-bit Java (the default) instead of 64-bit.
I recognized that Java for Mac/ARM should only be 64-bit, but perhaps your default download also grabbed the wrong version, and there's another more appropriate version.
3 Comments
Efren
on 29 Apr 2024
Mulazim Ali KHOKHAR
on 15 May 2024
I have the same problem. I tried the solution from Efren but it still just pops-in and pops-out and vanish. It's not stable to run the program. Any other solutions?
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!