Download the JDK
www.oracle.com/java/techno… Select the version you want to download. Remember to select the JDK version, not the JRE, otherwise the path will not be installed there when you set JAVA_HOME
Because of Android development, I chose to download JDK8. evernotecid://11C9A2F2-0F47-45EA-AD4B-A100BBE1C07A/appyinxiangcom/2742929/ENResource/p6094
Install the JDK
Double-click the downloaded.dmg file and install it as prompted.
Set the JAVA_HOME
Once installed, the JDK installation path is in: / Library/Java/JavaVirtualMachines / {} JDK version/Contents/Home.
By the way the JRE installation path is: / Library/Internet plug-ins/JavaAppletPlugin plugin/Contents/Home /
Set the ~ /. Following
- If the./bash_profile file exists, execute
$open -e ~/.bash_profile
Then fill in the following code. If no, run the command first$touch ~/.bash_profile
Fill in the following code again.
JAVA_HOME = / Library/Java/JavaVirtualMachines jdk1.8.0 _281. JDK/Contents/Home PATH =$JAVA_HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export JAVA_HOME
export PATH
export CLASSPATH
Copy the code
- perform
$source ~/.bash_profile
To take effect
How to set the MAC to ZSH. Bash_profile
The above.bash_profile may not work after reboot because ZSH is used instead of bash under MAC (MAC version 10.15.7) and ZSH loads ~/.zshrc files, and the ‘.zshrc ‘file does not define task environment variables.
Solutions:
At the end of the ~/.zshrc file, add the line source ~/.bash_profile