After Mac OSX 10.9, the system has brought its own Java 6 environment. The path is:
Copy code
The code is as follows:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
If you want to install and upgrade the environment to Java 7, the steps are as follows:
1. Download the installation package corresponding to JDK7 from Oracle official website,The address is hereAfter successful installation, the default path of JDK7 is:
Copy code
The code is as follows:
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
2. Configure environment variables after successful installation
In. Bash_ Add:
Copy code
The code is as follows:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
It should be noted that after Mac OS X 10.5, apple suggested setting up $Java_ Home variable to / usr / libexec / Java_ home
3. After setting, enter the following command to test
Copy code
The code is as follows:
$java -version
java version “1.7.0_60”
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)</p>
$/usr/libexec/java_home -V
Matching Java Virtual Machines (3):
1.7.0_60, x86_64: “Java SE 7” /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
1.6.0_65-b14-462, x86_64: “Java SE 6” /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_ 65-b14-462, i386: “Java SE 6” /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home</p>
$/usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
java version “1.7.0_60”
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)</p>
$/usr/libexec/java_home -V
Matching Java Virtual Machines (3):
1.7.0_60, x86_64: “Java SE 7” /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
1.6.0_65-b14-462, x86_64: “Java SE 6” /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_ 65-b14-462, i386: “Java SE 6” /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home</p>
$/usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home