Java is a general purpose, secured, robust, object-oriented language developed by Sun Micro-systems 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. This tutorial helps you to install Java 9 or Java 8 on macOS Sierra or High Sierra.
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.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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.
brew update brew tap caskroom/cask
Step 3 – Install JAVA with Homebrew Cask
Currently Java 9 and Java 8 available for installation. Use the following commands to view the details about java versions to be install.
brew tap caskroom/versions brew cask info java8 ## For Java 8 brew cask info java ## For Java 9 (latest version)
Now, install the Java version of your choice using one of the below commands. You can also install both versions if required.
brew cask install java8 ## Install Java 8 brew cask install java ## Install Java 9 (latest version)
I have only installed the Java 8 on my system. The download process may take some time to complete depending on your network speed. Once the installation finished, verify the installed Java version.
java -version java version "1.8.0_162" Java(TM) SE Runtime Environment (build 1.8.0_162-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)
All done. Your Mac system has installed Java on it.