How to Install Java Using Brew

Haider Ali Feb 02, 2024
  1. What are HOMEBREW and BREW
  2. Install Java Using Brew
How to Install Java Using Brew

This guide will show how to install Java using BREW.

What are BREW and HOMEBREW? What is needed to install Java using BREW?

The answers are found in this article, so let us start without further delay.

What are HOMEBREW and BREW

BREW (Binary Runtime Environment for Wireless) is used to create applications for wireless devices.

BREW is a set of APIs (Application Programming Interface) used to better understand its meaning to create software applications for wireless devices.

Some people get confused between the concepts of HOMEBREW and BREW, but there is no need for that since BREW is a core command for HOMEBREW. This means that BREW is a command that controls the behavior and the logic of the program in which HOMEBREW is used.

HOMEBREW is a project or package that makes installing a package in the MAC systems easier. It is an Open Source Software Package Manager, so BREW is its core command.

Another important thing to notice is that HOMEBREW only works for MAC systems. For it to work for a Windows Operating System, we have to look into the alternatives like Ninite.

Now that we have a clear distinction on BREW let us see how we can install Java using BREW.

Install Java Using Brew

First, when installing Java through BREW, we must ensure that HOMEBREW is successfully installed in our MAC system.

If it is not installed, we would have to type in the following command on the terminal.

ruby -e "$(curl -fsSL"

Next, we would have to install a HOMEBREW cask. Now, a cask is an extension allowing HOMEBREW to install graphical software since HOMEBREW does not support GUI.

To install the HOMEBREW cask, we must type this command in the terminal.

brew tap homebrew/cask-versions
brew update
brew tap caskroom/cask

Once HOMEBREW is successfully installed in our MAC systems, we can move on to installing Java using BREW. To do that, we must type this command in the terminal.

brew install java

Or you can add the keyword cask if you wish to install Java with GUI-supported software. For example:

brew cask install java

This command would install the latest version of Java, but if you do not wish to install the latest version but a previous one, we would have to add a different command. For example:

brew install openjdk@11

This would install Java version 8 in our MAC system.

If by any chance this installation does not work for your system. You would have to use this extra line of command and type it in the terminal of your MAC Operating System.

sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \

This would then install the latest version of Java. If you want to install a different version, that is also doable.

For that, you would have to type in this command.

sudo ln -sfn /opt/homebrew/opt/openjdk@8/libexec/openjdk.jdk \

Following these steps would help you to install Java without any difficulty.

Author: Haider Ali
Haider Ali avatar Haider Ali avatar

Haider specializes in technical writing. He has a solid background in computer science that allows him to create engaging, original, and compelling technical tutorials. In his free time, he enjoys adding new skills to his repertoire and watching Netflix.


Related Article - Java Installation