After install Java check what versions do you have:
$ java --version
Something like this will appear:
Matching Java Virtual Machines (2):
12, x86_64: "Java SE 12" /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
11.0.2, x86_64: "Java SE 11.0.2" /Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
Select the version you want:
/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
open your bash to edit:
$ sudo vi ~/.bash_profile
and add this line:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.2.jdk/Contents/Home
update your bash:
source ~/.bash_profile
confirm:
$ java --version
Recommended Posts