Install Homebrewīasically apt-get / rpm / yum / apk /, but for Mac. Tested on macOS Big Sur, but should work in other versions. This is what makes Maven and other tools use our default Java version until we change it using jenv. In this guide we will configure our environment using Homebrew, AdoptJDK 1.8, jenv, and set up our zsh to automatically load the appropriate java version and set JAVA_HOME for us whenever we start up the terminal.
This can be achieved by dynamically setting up the JAVA_HOME environment variable. Perhaps more importantly, other applications such as Maven should be aware of the version of Java that is active and use that one. An ages-long problem that once in a while comes to take a couple of hours away from a developer: How to properly manage multiple versions of Java in a single Mac, and how to switch between them painlessly.