#java [jenv](https://github.com/jenv/jenv) allows to switch between multiple Java versions (similar to nvm). This is how it works for me on macOS. ## Install the desired Java versions When trying to install older versions of Java (e.g. Java 8), this does not work anymore... ```sh brew install java8 ``` ... because Oracle does not support older JDKs and they are maintained by an open-source community. So, for Java 8, the following should work: ```sh brew cask install homebrew/cask-versions/adoptopenjdk8 ``` ## Install jenv Install [jenv](https://github.com/jenv/jenv) via homebrew. ## Add desired Java versions to jenv Check locally available Java versions with: ```sh /usr/libexec/java_home -V ``` That outputs the file paths of all versions available on the machine. Then tell jenv, which version(s) you want it to know: ```sh jenv add <filepath> ``` ## Switch between versions ```sh jenv local <java-version> # for the current terminal session jenv global <java-version> # for switching globally ``` --- Source: [Working with multiple Java versions in macOS](https://medium.com/@brunofrascino/working-with-multiple-java-versions-in-macos-9a9c4f15615a)