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
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!
which javashould return/usr/bin/java.ls /Library/Java/JavaVirtualMachines/should show ajdk-25.jdkdirectorywhich javaon Unixes is mostly pointless owing to the use of symlinks. On Linux, you wantreadlink -f "$(which java)"on Mac, you could dobrew install coreutilsin order to do this, but you need to prepend $HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin toPATHor you'll have to call itgreadlink