How To Download And Install Java On Mac

How to download and install java on mac

Java is a general-purpose, secure, robust, object-oriented language developed by Sun Microsystems in 1990. Java is portable which means it follows to write once run anywhere paradigm. Many of the useful application are build on Java and required Java runtime environment. If you are preparing your system for the developing new java applications, you need to install JDK on your machine.

The latest version is Java 14 which was released in March 2020. This tutorial helps you to install Java 14 latest version or Java 11 LTS on macOS Sierra or High Sierra.

Install Java For Mac

Java Help Center - Installing Java Results All Platforms Solaris SPARC Solaris x86 Red Hat Linux Oracle Enterprise Linux Oracle Linux SUSE Linux Windows 10 Windows 8 / Windows 8.1 Windows 7 Vista Windows XP Windows 2008 Server Windows Server 2012 Mac OS X / macOS Ubuntu Linux Linux.

Step 1 – Prerequisites

Before starting the installation of Java using this tutorial you must have the following prerequisites

  • Terminal: You must have Mac Terminal access and little knowledge about working with the terminal application. Ao login to your Mac system and open terminal
  • Homebrew: This tutorial relies on Homebrew, So you must have homebrew installed. Homebrew can be installed with a single command.
  • For more instruction visit Homebrew installation tutorial.

Step 2 – Install Homebrew Cask

On Mac systems, Homebrew is the package manager, and Homebrew Cask is the app manager built on top of Homebrew. You Execute command to update brew cache and tap the caskroom/cask.

Step 3 – Install JAVA with Homebrew Cask

At the time of writing this tutorial the available version, Java 11 LTS and Java 14 latest for the installation.

  1. Check Available Versions – Use the following commands to view the details about java versions to be install.
  2. Installing Java – Next, install the Java version of your choice using one of the below commands. You can also install both versions if required.

    The installation process may take some time to complete depending on your network speed.

  3. Check Version – Once the installation finished, verify the installed Java version.

All done. You have successfully installed Java on your macOS system.

Install Java On Mac Os

Conclusion

In this tutorial, you have learned to install Java on macOS systems using homebrew.

Introduction

Java is the most widely used general purpose, secured, robust, object-oriented language which was developed by Sun Microsystems in 1990. Java is portable which means it follows write once run anywhere paradigm. The latest version is java9 which was released on September 21,2017. In this tutorial, we will learn the installation process of Java on MacOS.

How To Download And Install Java On Mac Download

Prerequisites

  • MacOS
  • Login as an administrator in terminal

Installation

There are the following steps used to install Java on MacOS.

1) Download The latest version

We can visit the official website of oracle by simply pasting the link in the browser's search bar: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html and download the disk image file for MAC Operating System.

2) Mount the dmg file

The downloaded file is in .dmg format that is disk image file. On Mac Operating system, we can't install the dmg files by using installer command.

Installer command is used with the files that are in package format. To get the file in the desired format, we need to mount the file by using following command.

Hdiutil command is used with the option -mount to get the disk image file mounted. When we run this command, we'll get a mounted file with the same name but in the .pkg format. This file is located inside Volumes directory.

Java

3) Install the Package

Installer command is used to install the package. This can be done as shown below.

This command is used with the target option which represents the location where the package is to be installed. In this case, we are installing the package in the root directory. To run the installer command, we must have the super user privileges. For that purpose, sudo is used which prompts the user to fill the admin password. The command installs brand new Java 9 on our MacOS.

Java Download On Mac

4) Checking java version

To confirm, whether java is installed on the computer or not, we may use the java -version command as shown below.

5) Unmount the Disk Image File

Hdiutil command with unmount option is used to unmount the disk image file. Unmounting frees the volume which was used to store the package when we were installing the package.

Now if we search for the pkg file in the Volumes directory then we are not going to find it.

Extra Info

To use the java complier, we can simply type javac in the terminal. To Execute the java files, we can use java tool by simply typing, java <file-name> .

This is how, we can use java on MacOS installing through terminal.


Next TopicHow to Install Python on Mac