I am having a pathetic issue with Java in my mac osx 10.7.3 . Previously I installed it and it was working fine. After some changes in the .bash_profile and .profile file in
JAVA_HOME
is not the name of the java executable. But of the directory, java was installed in. The executable should be $JAVA_HOME/bin/java
.
The which
command is not helpful for you there. It will not give you the java home, but most likely this is just a wrapper or symlink to java installed in a very different directory.
In MacOS Catalina, run
sudo nano ~/.bash_profile
In bash_profile, add:
export JAVA_HOME=$(/usr/libexec/java_home)
source ~/.bash_profile
Verify by running java --version