I have Big Sur 11.2.1 from 18.02.2021. I had the same issue with JAVA_HOME path configuration. After reading a lot of information I solved my problem with next:

Install JDK 8: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html Java SE Development Kit 8u281

Install it as usual on your MacOS Big Sur.

Check JDK version:

java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

Check what versions of JDK are already installed on your machine:

/usr/libexec/java_home -V 
Matching Java Virtual Machines (2):
    1.8.281.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_281 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Get only one that you need:

/usr/libexec/java_home -v 1.8.0_281
/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home

On Catalina and Big Sur - there is Z-shell , to add Environment variables like JAVA_HOME there are two files for that: ~/.zshenv and ~/.zshrc, I couldn't make it work with first one. It worked for me like this:

nano ~/.zshrc

Add to that file this line:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_281)

Press Ctrl+X and save changes.

Then run command to apply that changes to current terminal:

source ~/.zshrc

After that you can check if everything is working with command:

echo $JAVA_HOME
it will print you: /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home

Restart your terminal and programs which will be using JAVA_HOME variable. For me it was Android Studio. Now everything works fine. I am new to Mac OS and it took me with 4hours to solve this. With Windows it's just done in a minute:)

Answer from yozhik on Stack Overflow
🌐
Code2care
code2care.org › home page › q › setting java_home in macos big sur
Setting JAVA_HOME in macOS Big Sur | Code2care
January 4, 2026 - If you recently updated macOS from Catalina to Big Sur and see some issues with Java - you can try installing Java by following this article - Install Java on macOS · If you are unable to access Java via IDE's like Eclipse, Netbeans, or IDEA IntelliJ, you can follow the below steps, ... Now type echoing $JAVA_HOME ...
🌐
Apple Developer
developer.apple.com › forums › thread › 666681
usr/libexec/java_home is completely broken on Big Sur
November 14, 2020 - I recently upgraded to Big Sur and the Java home problem started, after trying many solutions as suggested, I found a simple solution if you are using only 1 version of Java JDK · Code Block sudo vi /etc/zprofile press Shift + i Add the below lines in either of the ways at the end of the zprofile file. Code Block export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home" OR
Discussions

java - Wrong JAVA_HOME after upgrade to macOS Big Sur v11.0.1 - Stack Overflow
I don't quite remember where they were set, but they are now gone. 2021-05-24T18:32:44.19Z+00:00 ... Worked for me. I also had run "unset JAVA_HOME ;" before this. 2021-05-25T10:45:37.853Z+00:00 ... Thank you, the instruction was clear and worked perfectly. I encountered issues with building android apps in Ionic when my office macbook updated to Big Sur... More on stackoverflow.com
🌐 stackoverflow.com
change java version in macOS BigSur - Stack Overflow
I followed following steps to fix an issue to set java version I needed in macOS BigSur. : ... Matching Java Virtual Machines (3): 17 (x86_64) "Homebrew" - "OpenJDK 17" /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home 11.0.17.0-m1 (x86_64) "IBM Corporation" - "IBM Semeru Runtime ... More on stackoverflow.com
🌐 stackoverflow.com
java - How to set JAVA_HOME environment variable on Mac OS X 10.9? - Stack Overflow
So the command will be echo export ...r/libexec/java_home)" >> ~/.zshrc 2021-09-24T00:47:18.993Z+00:00 ... Save this answer. ... Show activity on this post. I just spent 2 hours setting this variable. The other answers did not work properly for me. I'm using macOS Catalina 10.15.4. ... Manually navigate there to make sure you don't ... More on stackoverflow.com
🌐 stackoverflow.com
Bazel fails to recognize valid $JAVA_HOME on macOS Big Sur
After upgrading to macOS Big Sur, all invocations of bazel output the following and immediately exit: $ export JAVA_HOME=$(/usr/libexec/java_home -v11) $ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home $ bazel build WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE. FATAL: Could not find system javabase. Ensure JAVA_HOME is set... More on github.com
🌐 github.com
11
November 13, 2020
🌐
Apple Developer
developer.apple.com › forums › thread › 660822
Big Sur doesn't track JAVA_HOME wh… | Apple Developer Forums
September 24, 2020 - I can confirm this is an issue on MacOS 11 Beta 8 (as well). Bottom Line: The delegate java commands use JAVAVERSION to route to the correct JDK, not JAVAHOME. So, Set JAVA_VERSION="1.8". Set JAVA_HOME too, but that's for other tools. The binaries /usr/bin/java and /usr/bin/javac (etc) are all the same binary which (I'm guessing) launch the correct command based on examining its first parameter and (as of Big Sur) the JAVA_VERSION environment variable.
🌐
Morning Star's blog
mls-tech.info › java › java-how-to-set-java-home-in-macos-big-sur
How to set JAVA_HOME in MacOS Big Sur | Morning Star's blog
August 21, 2021 - To set JAVA_HOME environment, we need find where the java is installed firstly. we can use the ‘java_home’ command to find it. ... After execution, the terminal display the list of java you installed and the default java version in your environment. Like this: You can see, in our environment, ...
🌐
Mkyong
mkyong.com › home › java › how to set $java_home environment variable on macos
How to Set $JAVA_HOME environment variable on macOS - Mkyong.com
January 19, 2021 - In fish, please use ‘(/usr/libexec/ja…)’. export JAVA_HOME=$(/usr/libexec/java_home) ^ from sourcing file .bash_profile called on standard input · source: Error while reading file ‘.bash_profile’ ... Due to recent Mac catalina update, by default terminal uses zsh. Zsh does not use .bash_profile. It uses ~/.zshrc file. Open up this file and add source ~/.bash_profile. Restart Terminal and it should work. Make sure your ~/.bash_profile file does not have source ~/.bash_profile line.
🌐
Lotharschulz
lotharschulz.info › 2021 › 01 › 11 › change-default-java-version-on-macos-11-bigsur-persist-it
Change Java version on Mac 11 BigSur & persist it – Lothar Schulz
January 11, 2021 - The JAVA_HOME variable is set to java version 15 after executing the brew install commands above. $ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/adoptopenjdk-15.jdk/Contents/Home · Changing the java version in macOS prior to version 11 would be:
Top answer
1 of 11
60

I have Big Sur 11.2.1 from 18.02.2021. I had the same issue with JAVA_HOME path configuration. After reading a lot of information I solved my problem with next:

Install JDK 8: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html Java SE Development Kit 8u281

Install it as usual on your MacOS Big Sur.

Check JDK version:

java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode)

Check what versions of JDK are already installed on your machine:

/usr/libexec/java_home -V 
Matching Java Virtual Machines (2):
    1.8.281.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_281 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Get only one that you need:

/usr/libexec/java_home -v 1.8.0_281
/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home

On Catalina and Big Sur - there is Z-shell , to add Environment variables like JAVA_HOME there are two files for that: ~/.zshenv and ~/.zshrc, I couldn't make it work with first one. It worked for me like this:

nano ~/.zshrc

Add to that file this line:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_281)

Press Ctrl+X and save changes.

Then run command to apply that changes to current terminal:

source ~/.zshrc

After that you can check if everything is working with command:

echo $JAVA_HOME
it will print you: /Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home

Restart your terminal and programs which will be using JAVA_HOME variable. For me it was Android Studio. Now everything works fine. I am new to Mac OS and it took me with 4hours to solve this. With Windows it's just done in a minute:)

2 of 11
58

Seems in macOS Big Sur v11.0.1 the behavior of the /usr/libexec/java_home -v ... command has changed: it is sensitive to the previously set value of JAVA_HOME environment variable.

Exact behavior is not clear, I couldn't find any documentation on this, but in my experiments it reported the version already set in JAVA_HOME, regardless of the -v switch:

% JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home /usr/libexec/java_home -v 1.8.0_162
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home

Additionally, I noticed that it reports nothing, if JAVA_HOME is set, but doesn't point to a valid java home (also for -V):

% JAVA_HOME=dummy /usr/libexec/java_home -v 1.7.0_45
% JAVA_HOME=dummy /usr/libexec/java_home -V
%

Solution is to ensure JAVA_HOME is not set before executing /usr/libexec/java_home:

% unset JAVA_HOME ; /usr/libexec/java_home -v 1.8.0_162
/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
Find elsewhere
🌐
Cool IT Help
coolithelp.com › home › java › how to setup java_home in mac os big sur? | installing java on macos 11 big sur
How to setup JAVA_HOME in Mac OS Big Sur? | Installing Java on macOS 11 Big Sur - Cool IT Help
September 20, 2023 - ... Step 1: Please open the bash_profile file in edit mode. command: open -a TextEdit.app ~/.bash_profile · Step 2: Download Java/JDK from the Oracle website and install it, then copy the path up to the ‘home’ folder update in the ‘bash_profile’ file, and save it.
🌐
Milovantomasevic
milovantomasevic.com › blog › stackoverflow › 2021-04-11-how-to-set-java-home-in-mac-permanently
How to set JAVA_HOME in Mac permanently?
April 11, 2021 - Milovan Tomašević focuses on software development for Enterprise Software Modernization, used by thousands. Expert in data platforms and digital transformation.
🌐
Medium
medium.com › developers-journal › how-to-set-java-home-environment-variable-on-mac-os-x-9cd799d80388
How to Set $JAVA_HOME environment variable on Mac OS X | by Vishal Saxena | Developers Journal | Medium
April 2, 2020 - How to Set $JAVA_HOME environment variable on Mac OS X In this journal entry we will see how we can setup the $JAVA_HOME environment variable on Mac OS X 10.5 or later versions. From OS X 10.5, Apple …
🌐
GitHub
github.com › bazelbuild › bazel › issues › 12502
Bazel fails to recognize valid $JAVA_HOME on macOS Big Sur · Issue #12502 · bazelbuild/bazel
November 13, 2020 - After upgrading to macOS Big Sur, all invocations of bazel output the following and immediately exit: $ export JAVA_HOME=$(/usr/libexec/java_home -v11) $ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home $ bazel build <anything> WARNING: Ignoring JAVA_HOME, because it must point to a JDK, not a JRE. FATAL: Could not find system javabase. Ensure JAVA_HOME is set, or javac is on your PATH.
Author   bazelbuild
🌐
Medium
medium.com › @akhiltheguitarist › setting-up-java-path-on-macos-11d51e89a55f
Setting up java path on macOS. So recently, I changed my work machine… | by akhil | Medium
September 24, 2021 - Step 2: Assign the java home with the value. Pick the required java version to be set and execute the below command with change to the java version as required.
🌐
Java67
java67.com › 2015 › 11 › how-to-set-javahome-path-in-mac-os-x.html
How to set JAVA_HOME (PATH) in Mac OS? Example Tutorial | Java67
From version 10.6 onward, it's recommended to set JAVA_HOME variable using /usr/libexec/java)home and not using something like /System/Library/Frameworks/JavaVM.frameworks/Version/1.6.0_22/Home, which is subject to change from release to release. In order to set PATH just add this JAVA_HOME/bin into PATH. These steps work in OS X version Lion, Mountain Lion, Mavericks, Yosemite, and even in the beta version of the latest Mac version OS X El Capitan.
🌐
Mac Install Guide
mac.install.guide › java › java-home
Set JAVA_HOME on Mac · Mac Install Guide · 2026
Using $(/usr/libexec/java_home) instead of a hardcoded path means your configuration survives Java updates. Minor version upgrades will not break your setup. Avoid hardcoded paths. A hardcoded path like /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home ties you to one specific installation. It requires manual updates and does not port well to other machines.
🌐
Apps Developer Blog
appsdeveloperblog.com › home › java › how to set java_home on macos
How to Set JAVA_HOME on macOS - Apps Developer Blog
April 20, 2020 - For example, open the terminal ... in the terminal window. ... To set the JAVA_HOME environment variable for a current user you will need to update the ~/.profile file....
🌐
CodeJava
codejava.net › java-core › set-java-home-in-macos-linux
How to set JAVA_HOME in macOS and Linux permanently
December 30, 2021 - Z-shell (zsh) is the default shell ... following command in terminal: cat > .zshrcThen type the following commands as content of the file: export JAVA_HOME=$HOME/jdk-17.0.1.jdk/Contents/Home...
🌐
TecAdmin
tecadmin.net › how-to-set-java_home-environment-variable-on-macos
How to Set JAVA_HOME environment variable on macOS – TecAdmin
April 26, 2025 - The /usr/libexec/java_home is the command line utility that returns the Path of the Java home directory from the current user’s settings. You can use this utility to set up the JAVA_HOME environment variable on your macOS.
🌐
Scaler
scaler.com › home › topics › java › setting up java_home and the ide on mac os
Setting up JAVA_HOME and the IDE on MAC OS - Scaler Topics
July 14, 2024 - Following are the steps that must be followed if a need arises to change the Java path on MAC: Step 1: First and foremost open the terminal window and type which java. It confirms if we have JDK.