A brief analysis of installing and uninstalling Java's JDK on Mac (share)

奋力向前
Release: 2021-09-02 13:59:20
forward
3587 people have browsed it

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.

A brief analysis of installing and uninstalling Java's JDK on Mac (share)

Uninstall steps

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
Copy after login

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
Copy after login

Installation

brew tap caskroom/versions
brew cask install java8   # 安装java8
#brew cask install java  #默认安装最新版本
Copy after login

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
Copy after login

Warning (2019.4. 17) The

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!

Related labels:
source:chuchur.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!