Document
How to Install Java on Mac

How to Install Java on Mac

How to install Java on MacOSIntroductionJava is the most widely used general purpose, secured, robust, object-oriented language which was developed by

Related articles

What is a Cloud Kitchen? Meaning, Advantages, and Startup Insights Ikea smart lighting guide: the best Ikea lights to buy 5 Best Gaming VPNs in 2024: Android, PC, Consoles & More How to Set Up and Use the ExpressVPN App for Raspberry Pi 2024年7月在Pixel7 Pro上使用前置代理连接Google VPN

How to install Java on MacOS

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.

Prerequisites

  • MacOS
  • Login as an administrator in terminal

installation

There are the follow step used to install Java on MacOS .

1) Download The latest version

We is visit can visit the official website of oracle by simply paste 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.

How to Install Java on Mac

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

3) Install the Package

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

How to Install Java on Mac

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

4 ) check java version

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

How to Install Java on Mac

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.