Installation <br />Because not all users need Java, OS X does not pre-install Java by default. You can install it manually if you need it.
1. http://support.apple.com/kb/DL1572
Go to Apple’s official website to download.
http://support.apple.com/downloads/DL1572/en_US/JavaForOSX2014-001.dmg
2.http://www.oracle.com/technetwor... ownloads/index.html
Go to Oracle to download the latest version of Java 8 JDK installation.
After installation, enter in the terminal
java-version
If the version is displayed, it means it is installed.
If the following is displayed, it means the installation is incorrect and you need to start over.
No Java runtime present, requesting install.
Find and set $JAVA_HOME on MAC
You can use the tool command "/usr/libexec/java_home" to locate JAVA_HOME:
Locating JAVA:
/usr/libexec/java_home -V
Matching Java Virtual Machines (1): 1.8.0_25, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/ Contents/Home
Alternatively, you can use the -V option to list all versions of JAVA_HOME:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):1.7.0_45, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home1.6.0_65-b14-462, x86_64: "Java SE 6 " /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
Configure JAVA_HOME:
$ cat ~/.profileJAVA_HOME=`/usr/libexec/java_home`export JAVA_HOME$ echo $JAVA_HOME/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home$ source ~/.profile $java