I'm trying to set JAVA_HOME in macOS 10.14. Currently there are 2 jdk versions (jdk-11.0.8.jdk
, jdk-14.0.2.jdk
) installed in /Library/Java/JavaVirtualMachines
and I've exported env variable in .bash_profile
export JAVA_HOME=`/usr/libexec/java_home -v 11`
In terminal all is ok. java -version
prints 11.0.8
, echo $JAVA_HOME
shows 11's directory.
But in ~/test.sh
file java -version
prints 14.0.2
, $JAVA_HOME
is empty. I tried to set env var in etc/profile
but no success. Does anyone know what could possibly cause this?