How to make Java 22 default version on High Sierra machine.

Joined
Feb 3, 2008
Messages
315
Reaction score
5
Points
18
Hello -- downloaded and installed Java 22 on my Mac (old machine running High Sierra, but the machine still works), and can't find it when I enter java -version. Still shows version 21.03 as the default.

Can anyone help me out as to what I haven't done, or what needs to be done?
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,037
Reaction score
2,444
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Did you install Java using the normal Java installer or something else? When you type 'which java' what do you get? I prefer to use Homebrew to install and manage these tools.
 

vansmith


Retired Staff
Joined
Oct 19, 2008
Messages
19,966
Reaction score
606
Points
113
Location
Queensland
Your Mac's Specs
Too many devices to list
It might be worth noting that this is because version 21.03 is earlier in your PATH environment variable than the newer version.

What do you get as output to the following commands:
Bash:
which java
echo $PATH
 
Joined
Oct 30, 2023
Messages
30
Reaction score
22
Points
8
Hello -- downloaded and installed Java 22 on my Mac (old machine running High Sierra, but the machine still works), and can't find it when I enter java -version. Still shows version 21.03 as the default.

Can anyone help me out as to what I haven't done, or what needs to be done?
It sounds like Java 21.03 is still showing up because it’s ahead of Java 22 in your `PATH`. First, check if Java 22 is properly installed by looking in `/Library/Java/JavaVirtualMachines/`. Then, update your `PATH` to include Java 22 by editing your shell configuration file (`.bash_profile`, `.zshrc`, etc.) and add the path to Java 22. You can also set Java 22 as the default version using the `java_home` command. Just run `/usr/libexec/java_home -V` to see all installed JDKs and then `export JAVA_HOME=$(/usr/libexec/java_home -v 22)` to switch to Java 22. After making these changes, reload your shell configuration with `source ~/.bash_profile` (or the equivalent file) and check the version with `java -version`. If you’re using Homebrew, you can manage versions with `brew install openjdk@22` and `brew link --force --overwrite openjdk@22`. This should sort out the version mismatch for you!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top