Ali cloud linux centos system jdk version can never be changed OpenJDK harm

Mentally scolded oracle a hundred times, the jdk downloaded from the oracle download website is all the same version. It turned out to be my fault.

[root@iZuf63g1c5ttsli31m56orZ java]# java -version
java version "1.7.0_91"
OpenJDK Runtime Environment (rhel-2.6.2.2.el6_7-x86_64 u91-b00)
OpenJDK 64-Bit Server VM (build 24.91-b01, mixed mode)

The contents of echo $JAVA_HOME, $CLASSPATH $PATH are all correct, but the input java version is always 1.7. I don’t know where to configure it. The configuration under the /etc/profile file has been modified.

resolution process

The normal display java version should be

$ java -version

java version "1.8.0_201"

Java(TM) SE Runtime Environment (build 1.8.0_201-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Prepare to uninstall the system's openjdk

[root@iZuf63g1c5ttsli31m56orZ java]# rpm -qa| grep jdk
java-1.8.0-openjdk-1.8.0.65-0.b17.el6_7.x86_64
java-1.6.0-openjdk-1.6.0.36-1.13.8.1.el6_7.x86_64
java-1.8.0-openjdk-headless-1.8.0.65-0.b17.el6_7.x86_64
java-1.7.0-openjdk-1.7.0.91-2.6.2.2.el6_7.x86_64

Execute the delete command#rpm -e --nodeps java-1.6.0-openjdk-1.6.0.36-1.13.8.1.el6_7.x86_64

Check again#rpm -qa| grep jdk found less, delete all to see

[root@iZuf63g1c5ttsli31m56orZ java]# java -version
-bash: /usr/bin/java: No such file or directory

Wrong report, haha

There should be a problem with the path

Look carefully, this $PATH is written in the front, fortunately I have good eyesight, the people in the front are too low, this order is wrong, most people think it’s nothing, just put $PATH in the back, so that PATH=  $ JAVA_HOME: $PATH, but this, where usr/bin/java is configured, I will not go into it for the time being, and students who know it are welcome to comment and discuss. 

Just record the download address of jdk8. You can only download the latest version of jdk directly on the oracle interface. After a long time, you can’t enter the download page of jdk8. It’s really vomiting blood for a long time.

1. Download java8

Official website manual download: Java Downloads | Oracle

After downloading the package, upload it to the opt directory of ECS, and then execute

cp jdk-8u351-linux-x64.tar.gz /usr/local/java/

decompress

tar -zxvf jdk-8u351-linux-x64.tar.gz 

Modify the configuration file

vi /etc/profile

The final addition is as follows

JAVA_HOME=/usr/local/java/jdk1.8.0_351
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

Guess you like

Origin blog.csdn.net/s_ongfei/article/details/127817819