Install and uninstall jdk in linux
Others
2020-04-18 22:55:10
views: null
1. yum uninstall
- Check if the JDK is installed in CentOS
yum list installed | grep java
:; centos7 comes with openjdk by default, openjdk is not the official JDK of Oracle, is an open source JDK, the official is the JDK of Oracle: openjdk may have compatibility issues.
- If there is a built-in jdk, delete the JDK that comes with centos
yum -y remove java-1.8.0-openjdk*
yum -y remove tzdata-java.noarch
- The result is displayed as Complete! Indicates that the uninstallation is complete
2. Manual uninstall
- Find the installation path
which java
(check the JDK installation path)
- Delete the folder where jdk is located
rm -rf ***
(*** is the path found in the first step)
- vim command to edit the file profile
vim /etc/profile
; delete the environment variables to configure the JDK, so the JDK uninstall is complete
3. Install JDK
- Download the linux version of JDK from Oracle's official website and upload it to Linux
- Create a new java folder to decompress the downloaded JDK
mkdir /usr/local/java
tar -zxvf jdk1.8.***
- Configure environment variables
vim /etc/profile
## 在"HISTSIZE=1000"底下添加环境变量的路径:
JAVA_HOME=/usr/local/java
CLASSPATH=.:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
JRE_HOME=$JAVA_HOME/jre
##在"export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC"下面添加:
export JAVA_HOME PATH CLASSPATH JRE_HOME
## 完成后保存退出,然后使配置生效
source /etc/profile
- Set the symbolic connection of java and javac
cd /usr/bin
ln -s -f /usr/local/java/jre/bin/java
ln -s -f /usr/local/java/bin/javac
- Restart the system (
reboot
), check whether the installation is successfulecho $JAVA_HOME
echo $PATH
echo $CLASSPATH
java -version
Origin www.cnblogs.com/huizhipeng/p/12728458.html