Switch between JDK 7 and JDK 8

How to switch between JDK 7 and JDK 8

Find the JDK

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

Install JDK 1.8

$ 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"

In case of JDK 7 → JDK 8

$ 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"
# ......

JDK 8 → In case of JDK 7

$ 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

Switch between JDK 7 and JDK 8
switch and EnumMap
Switch between GUI and CUI on CentOS6.
Install and switch between multiple Javas on Ubuntu
Difference between vh and%
Difference between i ++ and ++ i
Difference between product and variant
Difference between redirect_to and render
[Java] Difference between == and equals
Rails: Difference between resources and resources
Difference between puts and print
Difference between redirect_to and render
Difference between variables and instance variables
Relationship between Controller and View
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Connection between ViewModel and XML
Relationship between package and class
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
Differences between IndexOutOfBoundsException and ArrayIndexOutOfBoundsException
Difference between .bashrc and .bash_profile
Difference between StringBuilder and StringBuffer
Difference between render and redirect_to
Difference between render and redirect_to
How to dynamically switch between FIN and RST in Netty
Difference between instance method and class method
Difference between render method and redirect_to
Difference between interface and abstract class
Difference between == operator and equals method
Mutual conversion between Function and Consumer
[Java] Difference between Hashmap and HashTable
Relationship between ActiveRecord with_lock and cache
[Terminal] Difference between irb and pry
Install JDK and JRE on Ubuntu 16.10
[Ruby] Difference between is_a? And instance_of?
Difference between == operator and eqals method
Rough difference between RSpec and minitest
[Rails] Difference between find and find_by
Understand the difference between each_with_index and each.with_index
Difference between instance variable and class variable
This and that of the JDK
Relationship between database and model (basic)
[JAVA] Difference between abstract and interface
Difference between Thymeleaf @RestController and @Controller
Difference between Stream map and flatMap
Differences between Applet class and JApplet class
[Java] Difference between array and ArrayList
Difference between primitive type and reference type
Difference between string.getByte () and Hex.decodeHex (string.toCharaArray ())
Differences between Java and .NET Framework
[Java] Difference between Closeable and AutoCloseable
[Java] Difference between StringBuffer and StringBuilder
[Java] Difference between length, length () and size ()
[rails] Difference between redirect_to and render
[Android] Difference between finish (); and return;
Switch with CentOS7 series + JDK-9.0.1 + JDK1.8.0 + alternatives
Conversion between Kotlin nullable and Java Optional
Upgrade and switch Ruby versions on Windows 10