JAVA | How to install multiple Java versions on macOS
Preconditions
you're running on macOS
brew is installed
Step 1: Instal JDK(s)
Search for available JDKs
install a required version, e.g.
Step 2: Make JDK searchable
For the system, Java wrappers to find this JDK, symlink it with. Instead of openjdk@8
use your version.
Step 3: Add Java paths to environment variables
Add to the end of your file which is used to be running by default when the shell session is started. E.g. to the ~/.bashrc
or ~/.zshrc
Step 4: Conclusion and example of usage
Now by default, you will have Java 17 available
and to switch to other versions, you can simply call java8
or java11
Links
Last updated