Install JDK on Mac OS X
The purpose of this section is to guide you to install Java in your development environment. JDK is a shortcut for Java™ Platform, Standard Edition Development Kit
The JDK is a development environment for building applications, applets, and components using the Java programming language.
Latest version of JDK is JDK 8.
JDK 8 installation is mandatory if you want to target Android devices.
Navigate to the following URL :http://www.oracle.com/technetwork/java/javase/downloads/
Locate the button Java SE Downloads:
Click on this button.
On the next page select the latest release for the Mac OS X platform: jdk-8u112-macosx-x64.dmg.
Install the package.
Setup the JAVA_HOME system variable
Open the Terminal app and type the following command:
export JAVA_HOME=$(/usr/libexec/java_home)
To check the JAVA_HOME is correctly setup type the following commands:
cd $JAVA_HOME
pwd
ls
You should see the following result:
/Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
COPYRIGHT include
LICENSE javafx-src.zip
README.html jre
THIRDPARTYLICENSEREADME-JAVAFX.txt lib
THIRDPARTYLICENSEREADME.txt man
bin release
db src.zip
Persist the JAVA_HOME system variable for the current user
The JAVA_HOME system variable must be persisted when you leave and resstart a new Terminal Window.
One way to do this is to create or update a .profile file in the user's home directory. This file should contain all the commands that should be executed before the Terminal Window session starts.
Open the Terminal app and type the following commands:
cd $HOME
nano .profile
In the Text Editor, type the following line
export JAVA_HOME=$(/usr/libexec/java_home)
You should have a screen similar to the following screenshot:
To save the .profile file, type CTRL + X
, then type Y
followed by the ENTER
key.
Once done, quit the Terminal window, reopen a new one and type the following command to check if the system variable has been persisted:
echo $JAVA_HOME
You should have a non empty response.
References
https://support.apple.com/en-us/HT202292
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
http://www.oracle.com/technetwork/java/javase/documentation/index.html