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
sudo vi /etc/zprofile
press Shift + i
Add the below lines in either of the ways at the end of the zprofile file.
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home"
OR
export JAVA_HOME=$(/usr/libexec/java_home -v "1.8")