1. Download the appropriate version of the JDK:
wget--no-check-certificate--no-cookie--header "Cookie:oraclelicense=accept-securebackup-cookie;" http:// download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.rpm
Because the official website needs to register the login, so choose this code to download the corresponding version of the JDK;
2. Move the JDK to the appropriate CentOS directory:
MV Jdk-8u45-linux-x64.rpm/usr/java
3. Uninstall previous versions of JDK: delete this folder directly in the file directory
4. Install the new version of the JDK:
chmod 755 jdk-8u45-linux-x64.rpm//Add permissions to the installation package
RPM-IVH jdk-8u45-linux-x64.rpm//install JDK with RPM-IVH XXX command
5. View the environment variable configuration:
echo $PATH//If the path in the environment variable does not change, you need to manually configure the environment variable
[Email protected] desktop]# Vi/etc/profile
- Export java_home=/usr/java/jdk1.8.0_45
- Export Jre_home= $JAVA _home/jre
- Export path= $PATH: $JAVA _home/bin
- Export classpath=./: $JAVA _home/lib: $JAVA _home/jre/lib
: Wq//Save exit
6. Restart the server for the environment variable to take effect, and then view the JDK version:
[Email Protected]_18_87_centos ~]# java-version
Java Version "1.8.0_45"
Java (TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot (TM) 64-bit Server VM (build 25.45-b02, Mixed mode)
CentOS Upgrade JDK