MATLAB not detecting Java even after setting JAVA_HOME and MATLAB_JAVA
165 views (last 30 days)
Show older comments
I'm trying to configure MATLAB to use a specific Java Development Kit (JDK) on my Windows 11 system. I have installed Eclipse Adoptium JDK 17 and correctly set the following environment variables:
JAVA_HOME = C:\Program Files\Eclipse Adoptium\jdk-17.0.15.6-hotspot
MATLAB_JAVA = C:\Program Files\Eclipse Adoptium\jdk-17.0.15.6-hotspot
However, when I start MATLAB and run the command `jenv`, I get the following output:
>> jenv
ans = JavaEnvironment with properties:
Version: "Java is not enabled"
Home: "Java is not enabled"
Library: "Java is not enabled"
Status: notloaded
Configuration: "C:\Program Files\Eclipse Adoptium\jdk-17.0.15.6-hotspot"
>>
I've also added `%JAVA_HOME%\bin` to the system PATH.ings I've already tried:
- Verified the JDK version (it's 64-bit and not a JRE).
- Ensured the folder path is correct and accessible.
- Tried both user-level and system-level environment variables.
- Tried launching MATLAB from the command prompt after setting JAVA_HOME manually.
I'm not sure what I'm missing here. How can I get MATLAB to detect and use this installed JDK?
Any help would be appreciated.
P.S. I am just a student so please pardon me if I've made any silly mistakes in the post or maybe even in what I am trying to do🙇
jenv
1 Comment
Answers (2)
Martijn
on 19 Aug 2025 at 8:56
Note that MATLAB R2025a can in fact still use Java for example if you want to call Java from MATLAB, see:
And it should still be possible to use MATLAB_JAVA to instruct MATLAB which Java to use once it actually needs it.
However, since MATLAB's own graphical user interface is no longer Java based in R2025a, it is not longer automatically loaded at startup. That is why jenv shows that the Status is notloaded right after startup and as long as it is not loaded the other values will indeed list Java is not enabled.
To see/verify whether MATLAB is indeed able to use the alternative Java as you tried configuring here, after startup make sure you do in fact run some code which really uses Java e.g. s = java.lang.String('Hello World') before you use jenv. After you have run this, jenv should report that Java has been loaded and it should populate the Version and other attributes.
0 Comments
See Also
Categories
Find more on Startup and Shutdown 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!