In the previous article "Teach you how to install and configure homebrew using mac (code sharing)", I introduced you how to install and configure homebrew using mac. The following article will help you understand the JDK installation and uninstallation of Java on Mac. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Delete java files
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefpane sudo rm -fr ~/Library/Application\ Support/Java
Manual deletion may not be successful , it is recommended to go into the directory and check whether the file exists.
Delete jdk
#查找当前版本 #输入: ls /Library/Java/JavaVirtualMachines/ #输出:jdk-9.0.1.jdk sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk
brew tap caskroom/versions brew cask install java8 # 安装java8 #brew cask install java #默认安装最新版本
Configure Java environment variables
# 1.定位JAVA_HOME位置 /usr/libexec/java_home # 2.编辑profile文件 vim ~/.bash_profile # 3.格式参考 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar # 4.执行生效 source ~/.bash_profile # 5.检查是否成功 echo $JAVA_HOME
brew
method can no longer be installed. The official website of oracle
cannot be downloaded now (java8
). It prompts you to log in. After registering an account, you cannot log in for a long time. Just download it from Baidu Cloud.
The following is the download address, java8 for mac, take it without any thanks.jdk-8u201-macosx-x64 .dmg
New environment java12, project tossing After a long time, I suspected that it was a jdk version problem, so I returned to java8
Recommended learning: Mac OS Tutorial
The above is the detailed content of A brief analysis of installing and uninstalling Java's JDK on Mac (share). For more information, please follow other related articles on the PHP Chinese website!