I recently installed OpenJDK 25 using Homebrew. The installation completed successfully, but my terminal continued to report an older Java version.
The root cause turned out to be a conflict between jenv and another Java version manager. This post documents the diagnosis and the solution.
Install OpenJDK
brew install openjdk@25
Homebrew instructs you to register the JDK with macOS:
sudo ln -sfn \
/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk \
/Library/Java/JavaVirtualMachines/openjdk-25.jdk
Verify that macOS recognizes the JDK
Check that the JDK is visible to macOS:
/usr/libexec/java_home -V
You should see an entry for OpenJDK 25.
If macOS can detect the JDK, the installation itself is successful.
Add the JDK to jenv
By default, jenv does not automatically discover newly installed JDKs.
Add the JDK using:
jenv add "$(/usr/libexec/java_home -v 25)"
Verify that it has been registered:
jenv versions
You should see entries similar to:
system
25
25.0
openjdk64-25
Select Java 25
jenv global 25
jenv rehash
Confirm the selected version:
jenv version
If Java is still not changing
The most common cause is another Java installation appearing earlier in your PATH.
Check which executable is actually being used:
which java
If the result is not a jenv shim, then jenv is not controlling your shell.
Initialize jenv
Add the following near the end of your shell startup file:
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
Reload your shell:
source ~/.zshrc
or simply start a new terminal.
Enable JAVA_HOME management
If JAVA_HOME still points to another installation, enable the export plugin:
jenv enable-plugin export
Restart your shell afterwards.
Verify everything
which java
java --version
jenv version
echo $JAVA_HOME
Expected results:
which javapoints to ajenvshim.java --versionreports OpenJDK 25.jenv versionreports version 25.JAVA_HOMEis managed by jenv.
Key takeaway
Installing a JDK is only one part of the process. If multiple Java version managers are installed, whichever one appears first in your shell configuration controls the Java executable and JAVA_HOME.
If Java refuses to switch versions:
- Verify that macOS recognizes the JDK.
- Add it to jenv.
- Select it with
jenv global. - Ensure the jenv shims appear before other Java installations in your
PATH. - Enable the jenv
exportplugin so thatJAVA_HOMEstays synchronized.