## Assuming we have both java packages installed in the server
## Before Switch, confirm the version of java
[root@rhel7server1 java]# which java
/usr/bin/java
[root@rhel7server1 java]# java -version
openjdk version "1.8.0_292"
OpenJDK Runtime Environment (build 1.8.0_292-b10)
OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)
## run altertives command (binary is located at /sbin/alternatives)
[root@rhel7server1 java]# alternatives --config java
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
1 java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64/jre/bin/java)
*+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre/bin/java)
3 /usr/java/jdk1.8.0_281-amd64/bin/java
Enter to keep the current selection[+], or type selection number: 3
## Confirm the java version after the switch
[root@rhel7server1 java]# java -version
java version "1.8.0_281"
Java(TM) SE Runtime Environment (build 1.8.0_281-b31)
Java HotSpot(TM) 64-Bit Server VM (build 25.281-b31, mixed mode)
|