In this article, I will demonstrate how to install Java OpenJDK 15 on macOS Big Sur in 2021.
Update: I have created a video tutorial on how to install OpenJDK on macOS Big Sur:
If you prefer written instructions, just keep reading:
Download and Install OpenJDK 15
Download the .tar.gz
version of OpenJDK 15 from jdk.java.net/15/ and move the file to /Library/Java/JavaVirtualMachines/ on your mac. Then, extract it and delete the archive:
sudo mv openjdk-15.0.1_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines/ cd /Library/Java/JavaVirtualMachines/ sudo tar -xzf openjdk-15.0.1_osx-x64_bin.tar.gz sudo rm openjdk-15.0.1_osx-x64_bin.tar.gz
Next, execute the following command to find out where JDK 15 is located:
$ /usr/libexec/java_home -v15 /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home
and append the resulting path as an export into your .bash_profile
(or, change the existing JAVA_HOME
entry in your .bash_profile
if it already exists):
echo -n "\nexport JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home" >> ~/.bash_profile
and make sure to apply the changes:
source ~/.bash_profile
Test Java
You should now be able to run java:
java -version
Depending on your security settings, the following warning needs to be accepted by clicking “Open”:
You should then see an output similar to the following:
openjdk version "15.0.1" 2020-10-20 OpenJDK Runtime Environment (build 15.0.1+9-18) OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)
Congratulations! You have installed OpenJDK 15.
Sweet jesus, was ready to throw my laptop at the wall trying to fix my Java because nothing was adding up with other resources online until this parted the clouds! (And realizing maybe Big Sur was behind all this.) You saved my laptop and wall!
Thanks for this guide Bernhard!
Demonstration how to install Java OpenJDK 15 on macOS Big Sur in 2020 worked for me. Thank you so much – much appreciated!
Thank you so much! You are the best! ^_^
A side note: if you downloaded 15_0_2 version of the JDK, here is how the first 4 commands should look like:
“`
sudo mv openjdk-15.0.2_osx-x64_bin.tar.gz /Library/Java/JavaVirtualMachines/
cd /Library/Java/JavaVirtualMachines/
sudo tar -xzf openjdk-15.0.2_osx-x64_bin.tar.gz
sudo rm openjdk-15.0.2_osx-x64_bin.tar.gz
“`
Also, the JAVA_PATH update command will become:
“`
echo -n “\nexport JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home” >> ~/.bash_profile
“`
Finally, if you are using oh-my-zsh, then you should edit the file .zshrc (located on ~/.zshrc), and you might not even have the “.bash_profile” file.
Thank you! Glad i found this article!
Clear and very helpful – worked for me to restore functioning of Apache Directory Studio.
Thank you!
At 2min 30 sec in the video, what are you doing to exit Vim? I’m a newbie 🙁
You can exit vim by entering :q! and pressing enter. However, if you are new to vim, you can also use any other text editor to change the file content (e.g., nano or code).
Thanks for the clear steps. Used for Java 16.
One can also do:
export JAVA_HOME=$(/usr/libexec/java_home)
For bash or ~/.zshrc if on BigSur
Thanks! 👍