In this article, we shall learn how to download and install openjdk 15 from a tar file on MacOS.
In order to download openjdk, navigate to the official openjdk download site for java development kit 15. This site features download bundles for all different operating systems.

This article is written for Java 15 but the steps outlined here can be used for any java version which is downloaded as a tar file.

Since the bundle for macos is a tar file, we need to install java from tar file using the below steps.

1. Open terminal and navigate to the directory where the tar file was downloaded using cd command.
Normally, it would be Downloads folder.

2. Extract the tar file
Name of the tar file downloaded from the above link will be openjdk-15.0.1_osx-x64_bin.tar.gz.
Extract it using below tar command

tar -xf openjdk-15.0.1_osx-x64_bin.tar.gz

where,
x option means to extract the file.
f is used to give the file name to be extracted.

Type this command on the terminal and press enter(or return) key.
This will extract the tar file and create a new folder with name jdk-15.0.1.jdk in the same location.

3. Move the folder created in last step to the location where Mac looks for Java installations using mv command.
This location is /Library/Java/JavaVirtualMachines.

Since this requires administrative privileges, you need to run the command with sudo as shown below.

sudo mv jdk-15.0.1.jdk /Library/Java/JavaVirtualMachines/

You need to enter system password for super user.

Now, if this is the only jdk on your Mac os, you have successfully installed java 15 or java version of the tar file.
On the terminal, type java -version command and you should see the below output.

openjdk version “15.0.1” 2020-10-20
OpenJDK Runtime Environment (build 15.0.1+9-18)
OpenJDK 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)

In case you had any other java version installed on the system, then executing java -version will still show the older version.
For making java 15 as the default java, follow the steps mentioned in this article.

Hope this article was useful.

0
Close Menu

Never Miss an article !

Get the new post delivered straight into your inbox, enter your email and hit the button

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

codippa will use the information you provide on this form to be in touch with you and to provide updates and marketing.