Switch versions with alternatives after yum install java

Use alternatives

sudo yum -y install java-1.8.0-openjdk

#After the install is complete

JAVA_PATH=$(sudo alternatives --display java | grep priority | grep 1.8 | cut -d ' ' -f 1)
sudo alternatives --set java $JAVA_PATH

# java -Check with version

The confirmation environment is Amazon Linux ʻami-ceafcba8` (amzn-ami-hvm-2017.09.1.20180115-x86_64-gp2)

Useful

Regardless of whether it is good or bad, it is assumed that you want to install packages automatically with a shell script. In my case, I installed 1.8.0 on Amazon Linux and encountered it when trying to use embulk

I thought I'd remove 1.7.0 with yum remove, but I had ʻaws-apitools that depended on it, so I used ʻalternatives as an alternative. It seems that the method of switching with ʻalternatives --config java` has come to the top.

Recommended Posts

Switch versions with alternatives after yum install java
Install Java8 with Yum on Amazon Linux
Install java with Homebrew
Install Java with Ansible
Easily switch Java versions with alias on macOS
Switch java with direnv
Install Java 7 with Homebrew (cask)
Seasonal display with Java switch
Install Java and Tomcat with Ansible
[Java] Branch enum with switch statement
Install Java with zip on Windows
Switch with CentOS7 series + JDK-9.0.1 + JDK1.8.0 + alternatives
How to switch Java versions on Mac
How to switch between multiple Java versions
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Error with bundle install after upgrading to Catalina
What is installed with yum / dnf group install
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Java SE Development Kit 8u161 --setup with alternatives
Switch between multiple versions of Java on Mac
Java switch statement
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
Install Java 8 (OpenJDK: Zulu Community) on macOS with Homebrew