The system comes with JDK uninstallation:
- java path query:
whereis java
- Find the JDK:
rpm -qa | grep jdk
andrpm -qa | grep gcj
- Uninstall the found JDK of the system:
yum -y remove
java-1.8.0-openjdk-headless-1.8.0.242.b08-0.el7_7.x86_64
1. Prepare
Create a file
mkdir /user/local/java
Enter the file directory
cd /user/local/java
2. Download
It is recommended to download the package from the official website first, and then upload and decompress it for use.
Official website: https://www.oracle.com/cn/java/technologies/downloads/
Installation package link:
https://download.oracle.com/otn/java/jdk/8u361-b09/0ae14417abb444ebb02b9815e2103550/jdk-8u361- linux-x64.tar.gz
pull down, find Java8:
select the Linux version, select the tar.gz version
2.1 Two methods
2.1.1 Download to local first, then upload ( 推荐!
)
Use tools such as xftp to upload jdk to
/usr/local/java/
2.1.2 Online download ( 不推荐!
)
Online download, it is recommended to replace the domestic source, the download is faster, refer to my article, click to jump
wget https://download.oracle.com/otn/java/jdk/8u361-b09/0ae14417abb444ebb02b9815e2103550/jdk-8u361-linux-x64.tar.gz
Because after downloading online, the compressed package may be incomplete, and an error will be reported when decompressing.
I'm just a 4KB file... I don't know why
For example:
3. Unzip
Make sure the file is /usr/local/java/
under , unzip the command:
tar -zxvf jdk-8u361-linux-x64.tar.gz -C /usr/local/java/
4. Set environment variables
vi ~/.bash_profile
Add to:
# Java
export JAVA_HOME=/usr/local/java/jdk1.8.0_361
export PATH=$JAVA_HOME/bin:$PATH
Exit editing, save and exit
Press ESC
and:wq
5. Check the environment
The environment configuration takes effect: source ~/.bash_profile
(Restarting the server reboot
can also take effect, it is recommended to use the above command)
Verify whether the installation is successful:java -version
Done, thanks for reading~
END