Installation of JDK (Java Development Kit) on MacOS

Author
By Darío Rivera
Posted On in Java

Basically, there are two sources to install Java. The first is the official Oracle repository which allows us to use the JDK legally depending on the use we give it. The second way to install the JDK is through a release of OpenJDK. This last option ensures that you are using a 100% legal version of Java. In this tutorial, we will see the installation from the OpenJDK source.

Installation with Homebrew

To install with Homebrew you can search for the available list of java packages with the following command.

brew search jdk

To install, just run the following command with the selected version.

brew install openjdk@11

Installation from a file

The first step is to download the version of the JDK you want to install from the following official OpenJDK website.

http://jdk.java.net/

For the purpose of this tutorial, we will install version 14 of the JDK. Remember that this version is not LTS (Long term support) so its support is 6 months. Personally, I recommend installing only LTS versions. The last LTS version of JDK is 11.

After downloading the file for MacOS/x64, we must decompress the compressed file and the resulting folder (in our case jdk-14.jdk), it must be placed in /Library/Java/JavaVirtualMachines. Once this is done, you must verify the installation by executing the following command in the terminal.

mypc:~ someuser$ java --version
openjdk 14 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

Don't worry if you already had a previous version of the JDK installed. It's enough to just copy the folder inside JavaVirtualMachines and the system will automatically detect the new version.


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.