With Homebrew and Jenv:
Assumption: You have a Mac and have already installed homebrew.
Install Java from the Oracle website. JDK can be installed in multiple versions. It will be installed in the following location:
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/
/Library/Java/JavaVirtualMachines/jdk1.11.0_2.jdk/
/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/
Without jenv, the system will use the most recently installed java.
You can use jenv: if you want to use/manage multiple versions.
Install and set up jenv:
$ brew install jenv
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc
$ source ~/.zshrc
Add the installed java to jenv:
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/14.0.2.jdk/Contents/Home
To see all the installed java:
$ jenv versions
Above command will give the list of installed java:
system
1.8
* 1.8.0.291 (set by /Users/lpatel/.jenv/version)
14
14.0
14.0.2
oracle64-1.8.0.291
oracle64-14.0.2
Configure the java version which you want to use:
$ jenv global 1.8.0.291