Upgrade the JDK that comes with CentOS

View the original version:
# java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

View java program path:
# which java
/usr/bin/java

View java related paths:
# whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/lib64/java /usr/share/ java /usr/share/man/man1/java.1.gz

View JAVA_HOME environment variable
# echo $JAVA_HOME
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64
Note: If there is no configuration "/ etc/profile" file, the value of "$JAVA_HOME" will not be output.


# /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64/bin/java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (rhel-2.5.5.1.el6_6-x86_64 u79-b14 )
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)

Check PATH environment variable
# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin: /usr/local/bin:/usr/bin:/bin:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64/bin:/root/bin

From the above observation, CentOS is installed by default The OpenJDK directory is
"/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64" (for development environment)
CentOS also copied java javac in the /usr/bin/ directory during system installation and other programs (for production environment, equivalent to the role of jre)

installation method: rpm installation
software under gnome: jdk-8u74-linux-x64.rpm
download address: http://www.oracle.com/technetwork/java/
Double-click to install javase/downloads/index.html after downloading.
After installation (and no successful prompt), check the version again:
# java -version
java version "1.7.0_79" It can be
seen that it does not work. Check that there are 3 more (default; jdk1.8.0_74; latest) directories in the /usr/java/ directory, and check the JDK version of this folder:
# /usr /java/default/bin/java -version
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode )
According to the returned information, it can be determined that the installation package has indeed run successfully, but the environment variables such as JAVA_HOME have not been modified.

View and modify the system configuration file
vi /etc/profile
to find the original configuration:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/ rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
#****************** ********** Change
to:
export JAVA_HOME=/usr/java/default/
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

save after modification.
source /etc/profile to make the settings take effect . The

environment variable configuration is complete. It should be noted that when the PATH is configured, you must put $JAVA_HOME/bin in the front, otherwise when using the java command, the system will find the previous java, and will not look down. In this way, the directory where the java executable file runs is not actually under $JAVA_HOME/bin, but in other directories, it will cause great problems.

Official installation instructions:
The RPM package creates two links: /usr/java/latest and /usr/java/default.
The /usr/java/latest link will always point to the version of Java that is considered the latest version . Subsequent upgrades of the package will overwrite this value if it is not the latest version.
 
By default, /usr/java/default points to /usr/java/latest.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326692418&siteId=291194637