How to switch between JDK 7 and JDK 8
Let's search for the package with the command.
$ yum search openjdk
Loaded plugins: priorities, update-motd, upgrade-helper
12 packages excluded due to repository priority protections
======================= N/S matched: openjdk =============
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in single archive
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
$ yum install java-1.8.0-openjdk
#
#Confirmation is complete when the installed Java version is displayed.
#
$ java --version
java version "1.8.0_141"
$ java -version
#
# output
# java version "1.7.0_151"
# ....
#
$ alternatives --config java
#
# output
#
# There are 3 programs which provide 'java'.
#
# Selection Command
# -----------------------------------------------
# *+ 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
# 2 /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
# 3 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
#
# Enter to keep the current selection[+], or type selection number:
#
# input 2
$ java -version
#
# output
# openjdk version "1.8.0_141"
# ......
$ java -version
#
# output
# java version "1.8.0_141"
# ....
$ alternatives --config java
#
# output
#
# There are 3 programs which provide 'java'.
#
# Selection Command
# -----------------------------------------------
# * 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
# + 2 /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
# 3 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
#
# Enter to keep the current selection[+], or type selection number:
#
# input 1
$ java -version
# output
# openjdk version "1.7.0_151"
# ......
end I hope it will be useful for your work.
Recommended Posts