CentOS jdk-8u361-linux-x64 installation configuration record

The system comes with JDK uninstallation:

  1. java path query:whereis java
  2. Find the JDK: rpm -qa | grep jdkandrpm -qa | grep gcj
  3. Uninstall the found JDK of the system: yum -y removejava-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:
jdk8
select the Linux version, select the tar.gz version
x64

2.1 Two methods

2.1.1 Download to local first, then upload ( 推荐!)

official website , download

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

Online Download

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:
report error


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

Order

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 ESCand:wq


5. Check the environment

The environment configuration takes effect: source ~/.bash_profile
(Restarting the server rebootcan also take effect, it is recommended to use the above command)
Verify whether the installation is successful:java -version
Successful installation


Done, thanks for reading~
END


Guess you like

Origin blog.csdn.net/qq_44870331/article/details/129641888