1.Mac default Java installation path/system/library/frameworks/javavm.framework/versions/current/commands/java (JDK1.6 installed by default via Mac system),
If the installation path is downloaded via Oracle's official website:/library/java/javavirtualmachines/jdk1.8.0_121.jdk/contents/home/bin/java
Official download page: Select Mac OS X DMG format
Find-shell Code:
$ which Java
/library/java/javavirtualmachines/jdk1.8.0_121.jdk/contents/home/bin/java
Verify: (Why the Address bar is displayed above.) Please click)
2. Configure Environment variables:
Shell Code
Vim. Bash_profile
Add Content:
Export java_home=/library/java/javavirtualmachines/jdk1.8.0_121.jdk/contents/home
export classpaht=.: $JAVA _ Home/lib/dt.jar: $JAVA _home/lib/tools.jar
export path= $JAVA _home/bin: $PATH
Click the ESC key again to end the edit
and enter the ": Wq" store to leave (: Wq. Force modification)-PS: Colon is required
Then enter "Source ~/.bash_profile" (Effective immediately after modification)
Shell Code
Java-version
Results:
PS: If it appears
No Java Runtime present, requesting install.
Please check the configuration is correct, repeat the above configuration operation can ~