Homebrew is a free open-source package manager for macOS and Linux that allows apps and software to be installed quickly and easily via Terminal. Homebrew describes itself as „the missing package manager for macOS“. The practical package manager also updates software with a single command.
Installation of Homebrew
To install Homebrew, all you have to do is run the install script in the terminal. This install script downloads Homebrew from Github and then installs itself.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Further information on installing Homebrew can be found in the documentation of Homebrew.
Install Java with Homebrew
Now we can start to install the current version of java with Homebrew.
brew install java
A specific version can be installed with the following command. A symlink must then be created for this to work properly.
brew install openjdk@11 sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
Check the installation
You can check the installation of Java with the following command.