Reputation: 321
I have Java 8 installed on my centos7 machine, and I want to switch to adoptopenjdk 11. I've installed it through rpm, but no idea which directory it is located. which java
shows the old java 8 location.
I don't need Java 8 anymore, how can I change to 11?
[user@centos ~]$ 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)
[user@centos ~]$ sudo yum install adoptopenjdk-11-hotspot
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
AdoptOpenJDK | 1.4 kB 00:00:00
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
jenkins | 2.9 kB 00:00:00
nhn-epel | 2.5 kB 00:00:00
nhn-epel-noarch | 2.5 kB 00:00:00
update | 2.9 kB 00:00:00
AdoptOpenJDK/7/x86_64/primary | 58 kB 00:00:01
AdoptOpenJDK 234/234
Resolving Dependencies
--> Running transaction check
---> Package adoptopenjdk-11-hotspot.x86_64 0:11.0.11+9-3 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
adoptopenjdk-11-hotspot x86_64 11.0.11+9-3 AdoptOpenJDK 184 M
Transaction Summary
====================================================================================================================
Install 1 Package
Total download size: 184 M
Installed size: 306 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /home1/sys-var/cache/yum/x86_64/7/AdoptOpenJDK/packages/adoptopenjdk-11-hotspot-11.0.11+9-3.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 74885c03: NOKEY
Public key for adoptopenjdk-11-hotspot-11.0.11+9-3.x86_64.rpm is not installed
adoptopenjdk-11-hotspot-11.0.11+9-3.x86_64.rpm | 184 MB 00:02:38
Retrieving key from https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
Importing GPG key 0x74885C03:
Userid : "AdoptOpenJDK (used for publishing RPM and DEB files) <[email protected]>"
Fingerprint: 8ed1 7af5 d7e6 75eb 3ee3 bce9 8ac3 b291 7488 5c03
From : https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : adoptopenjdk-11-hotspot-11.0.11+9-3.x86_64 1/1
Verifying : adoptopenjdk-11-hotspot-11.0.11+9-3.x86_64 1/1
Installed:
adoptopenjdk-11-hotspot.x86_64 0:11.0.11+9-3
Complete!
Upvotes: 0
Views: 2440
Reputation: 439
try update-alternatives --config java
It will show you a list of installed jdks and you can pick which one you want to be the default:
[root@host /]# update-alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 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)
2 /usr/lib/jvm/adoptopenjdk-11-hotspot/bin/java
Enter to keep the current selection[+], or type selection number: 2
Upvotes: 1