Matlab does not find Java Runtime Environment (Mac Silicon)

277 vues (au cours des 30 derniers jours)
Efren
Efren le 24 Avr 2024
Commenté : Vincent le 11 Oct 2024
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 commentaires
Chris
Chris le 19 Août 2024
Modifié(e) : Chris le 19 Août 2024
@Aditya, according to this page, Java/Corretto is currently only supported up to version 17.
XING
XING le 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。
能够正常运行了

Connectez-vous pour commenter.

Réponses (2)

Marius
Marius le 28 Sep 2024
Modifié(e) : Marius le 28 Sep 2024
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 commentaires
Matei
Matei le 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
Vincent le 11 Oct 2024
You are the GOAT

Connectez-vous pour commenter.


Travis Massey
Travis Massey le 25 Avr 2024
Modifié(e) : Walter Roberson le 25 Avr 2024
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 commentaires
Mulazim Ali KHOKHAR
Mulazim Ali KHOKHAR le 15 Mai 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?
Efren
Efren le 15 Mai 2024
Modifié(e) : Efren le 15 Mai 2024
Did you check my comment above, in the original question? I give a step by step of te solution I found. (see my comment in response to Plante jean-luc's comment).

Connectez-vous pour commenter.

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by