Java is one of the most used programming languages for backend and creating different type of applications ( web application, mobile applications, desktop applications, and many more). It supports all the major operating systems such as Windows, Linux, Solaris, and MacOS. In this topic, we will see how to install Java on mac and its different variations.
Before proceeding further, let’s have a look at the quick index of the topic:
System Requirements to install Java on mac
Java SE 8 Archive Downloads (JDK 8u211 and later) Go to the Oracle Java Archive page. The JDK is a development environment for building applications using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the Java TM platform.
The system requirements and considerations for installing the JDK and the JRE on macOS are as following:
Important points to be considered while installing Java on MacOS:
Setup file jre-11-ea+8osx-x64bin.dmg - 75.39 MB - Mac - Support. All files are original. Download3K does not repack or modify downloads in any way. Check SHA1 and MD5 for confirmation. Select a download mirror: Download3k US (ver 10.0.1 / 11 Early Access 8, jre-11-ea+8osx-x64bin.dmg) Download3k EU (ver 10.0. Mac OS X Yosemite (and the newer versions) are having a later version of Java Runtime (SE 8.0). However, Java Runtime is not backward compatible. So, even when the operating system have installed Java Runtime 8, it will NOT run apps that rely on Java Runtime 6. Here is how to get Java 6 on your Mac. Install Legacy Java SE 6: Method #1.
Java Runtime Environment (JRE) 8 for Mac Price: Free: Version: 8: Release Date: August 20, 2016: Category: Utilities: Operating Systems. Java Runtime Environment (JRE) 8 for Mac Price: Free: Version: 8: Release Date: August 20, 2016: Category: Utilities: Operating Systems.
A computer running macOS and having administrator privileges.
Java can not be installed for a single user instead it is installed systemwide for all users.
The JDK package contains JRE by default. However, the current JRE version will not be replaced with the lower version of JRE.
Installing the JRE will not contain the JVM or other Java libraries for creating applications. It can only be used to run the Java apllications. See the difference between JRE, JDK, and OracleJDK.
Hardware requirements:
The following requirements should be meet to install Java 7 or later versions:
Intel-based Mac running versions 10.7.3 and above
Administrator privileges
A 64-bit browser (e.g., Safari)
32-bit browsers do not support Java 7 and later versions on the Mac platform
Determining the JRE Version Installed on macOS
There can be only one JRE version on the system. Installing the JRE will replaces the previous version. However, it will not replace with the older versions.
The JRE version can be determned by the following ways:
Visit System Preferences->Other section->Java . This will start the Java Control Panel, after this, click on About to display the version information.
Or,
Enter the following command on terminal:
The above command will display the installed Java version.
Determining the Default JDK Version on macOS
To start a Java application, the system uses the default JDK version. It is possible JRE may have the a different version that the JDK.
There can be multiple versions of the JDK, but, the JRE version can be only one (latest).
To determine the installed Java version, execute the below command:
The above command will display the output something like this ( for Java 10):
To change the default version version of Java, either specify the full path, or use the java_home tool as follows:
Installing the JDK on macOS
The JDK package by default contains the associated JRE versions. The JavaFX SDK and Runtime are also packaged into the standard JDK package.
Follow the below steps to install Java on MacOS:
Step1:
Download the JDK .dmg file from Here, or by executing the below command:
before downloading the file you must accept license agreements.
Step2:
After the successfull Double click on the ‘.dmg’ file to start the installation process.
Step3:
Next, you will see a finder window having the name of the ‘.pkg’ file. Click on the ‘.pkg’ file to proceed the installation process:
Step4:
In this step, you will see a Introduction window, click Continue.
Step5:
You will see a installation type window, Click Install to continue.
Step6:
In this step you will see a window having a message “Installer is trying to install new software”. Type your administrator password to allow this.
Step7:
Enter the Administrator user name and password and click Install Software.
The downlaoded Java version is installed on your machne and confirmation window is displayed.
Installing the JRE on macOS
Follow the below steps to install the JRE on an macOS platform:
Step1:
Download the JRE .dmg file, by executing the below command:
Accept the license agreement.
Step2:
Next, double-click on the .dmg file and launch it.
Step3:
In this step, you will see a finder window appears having ‘.app’ file.
Step4:
Double-click on the Java 10.app icon, it will start the installation process.
Step5:
The installation process will display the Welcome window, Click Next to continue the process.
Step6:
Hence, the downloaded JRE version is installed and a confirmation window is displayed. Click Close to complete the process.
Installing By Homebrew
To install By Homebrew package manager, follow the following steps:
Step1: Install Homebrew and update it, and download openJDK package by executing the below commands:
Step2: Find all available JDK versions by executing the below command:
The output will be something like this:
Step3: Select Java versions like Java 8, 9, 10, 11, 12, 13 by executing the one of the following commands:
Step4: for example to install Java 8 and 11, execute the below commads:
brew cask install adoptopenjdk8
brew cask install adoptopenjdk11
Step5:
To display the loaction where Java is installed, execute the below command:
The above command will display the output something like this:
Homebrew will install the JDK at Mac’s standard folder for Java “/Library/Java/JavaVirtualMachines/”.
Step6:
Verify the installation, by executing the below command:
The output will be as:
By default, Mac takes the Higher version of Java.
Version Switching
To change the default version of Java create or edit the “~/.bash_profile” with the text editor of your choice like vim or nano, export JAVA_HOME variable to the specified JDK we want to use on Mac.
Execute the below command:
Update the file as:
~/.bash_profile:
The above script will make the Java 8 as default Java version.
Uninstalling the JDK on macOS
To uninstall the JDK on macOS, Navigate to “/Library/Java/JavaVirtualMachines”. Remove the directory whose name matches the following format:
For example, to uninstall Java 10, execute the below command:
Note: Do not try to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time that you perform an update of the OS.
Uninstalling the JRE on macOS
To uninstall JRE, Navigate to “/Library/Internet Plug-Ins”. From here, remove the JavaAppletPlugin.plugin directory.