0

I installed Java 25 on my Mac running macOS Ventura 15.5. I downloaded the installer from Oracle’s official website and completed the installation. However, when I try to verify the installation in the terminal, Java is not found:

I ran the following commands after installation:

  • java -version
  • which java
  • ls /Library/Java/JavaVirtualMachines/

What I expected:
I expected to see the installed Java version, e.g. java version "17.0.x", and for which java to point to the correct path.

What actually happened:
Instead, I got:

zsh: command not found: java
6
  • please add a focused, answerable question to your post Commented Sep 30 at 9:12
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Sep 30 at 9:12
  • 1
    Have you read this, specifically the "To run a different version of Java..." part? Commented Sep 30 at 9:20
  • which java should return /usr/bin/java. ls /Library/Java/JavaVirtualMachines/ should show a jdk-25.jdk directory Commented Sep 30 at 9:28
  • which java on Unixes is mostly pointless owing to the use of symlinks. On Linux, you want readlink -f "$(which java)" on Mac, you could do brew install coreutils in order to do this, but you need to prepend $HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin to PATH or you'll have to call it greadlink Commented Sep 30 at 18:07

1 Answer 1

1
  1. Try reinstalling Java. One way you can do this is through the Java 25 JDK installer for MacOS from Oracle: https://www.oracle.com/java/technologies/downloads/#jdk25-mac

  2. After running the installer, open your terminal and run the command java -version to ensure your Java installation was added to your PATH. You should see something like this:

java version "25.x.x" 2025-XX-XX
Java(TM) SE Runtime Environment (build 25...)
Java HotSpot(TM) 64-Bit Server VM (build 25...)

If the command failed, try checking your JVM directory, go to: /Library/Java/JavaVirtualMachines, you should see directories listed like this (I have multiple Java installations):

Finder JVM Directory Example

If the directory is in there but the Java command from earlier was not recognized, add to PATH by typing the following into your terminal: nano ~/.zsh_profile or nano ~/.zshrc.

Using your down arrow key, go to the bottom of the file and type export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home".

This will set the JAVA_HOME variable that many Java-based apps use to find the JDK.

IMPORTANT: Make a new line underneath, and type export PATH="$JAVA_HOME/bin:$PATH".

This will tell the shell to look for commands in the Java bin directory.

Press ^X (control+x) keyboard shortcut to exit, press Y to confirm the change, and press return to save it to the file. COMPLETELY CLOSE YOUR TERMINAL AND OPEN A NEW ONE.

Now when you run java -version, it should hopefully work as expected!

Sign up to request clarification or add additional context in comments.

1 Comment

Correction: There is no “official Java 25 JDK installer for MacOS”. You can obtain a JDK/JRE (implementation of Java) from any of several vendors. These include: Amazon, BellSoft, Adoptium by Eclipse Foundation, IBM, Red Hat, Azul Systems, Microsoft, Oracle, SAP, and more. All of these are “official” in that they have been extensively tested. See: Java Is Still Free.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.