This tutorial is specific to OSX users currently. I haven't tested it anywhere else. If you can help in writing for other environments, please do contribute.
brew update
brew tap caskroom/cask
brew install brew-cask-completion
brew tap caskroom/versions
brew cask info [java version]
brew install jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(jenv init -)"' >> ~/.profile
brew-cask provides a friendly homebrew-style CLI workflow for the administration of macOS applications distributed as binaries
brew cask install [java version]
Now as the jenv doesn't know about the multiple java versions that are installed, we will add them manually!
jenv add /Library/Java/JavaVirtualMachines/[jdk versions here]/Contents/Home
You can automate this by the script after this literature (jenv_add.sh)
You can now switch versions easily by
jenv global/local/shell [java version]