[JAVA] Install OpenJDK8 with RPM

Now that we are migrating from Oracle JDK to OpenJDK, we will summarize the OpenJDK installation procedure.



$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)


1. Get openJDK

It may be good to search from around this site. https://pkgs.org/download/openjdk What I dropped this time * java-1.8.0-openjdk-headless- * java-1.8.0-openjdk-

$ wget 'http://mirror.centos.org/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-headless-'
$ wget 'http://mirror.centos.org/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-'

2. Various updates

Even if you install it as it is, an error will occur, so update the following

$ yum update copy-jdk-configs
$ yum update nss

3. Installation

Since headless is the main, let's install headless first.

$ rpm -ivh java-1.8.0-openjdk-headless-
$ rpm -ivh java-1.8.0-openjdk-

The installation destination is / usr / lib / jvm. It's completely different from the Oracle JDK.

drwxr-xr-x 3 root root 16 May 9 22:55 java-1.8.0-openjdk-
lrwxrwxrwx 1 root root 21 July 26 15:30 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 July 26 15:30 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 35 July 26 15:30 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx 1 root root 49 July 26 15:30 jre-1.8.0-openjdk- -> java-1.8.0-openjdk-

4. Check version control

It seems to be managed by alternative. When I installed it with rpm, it automatically turned to openjdk, so I will omit it this time.

# alternatives --config java

There are 2 programs'java'To provide.

Select command
   1           /usr/java/jdk1.8.0_162/jre/bin/java
*+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-

Press Enter to select the current[+]Or enter the selection number:

5. Change the direction of the version that can be confirmed with java -version

It seems that it is necessary to rewrite JAVA_HOME in /etc/profile.d/java.sh Will it be rewritten as yum? ..

$ cd /etc/profile.d/
$ vi java.sh
export JAVA_HOME=/etc/alternatives/jre #Add this
#export JAVA_HOME=/usr/java/latest #Comment out or delete

$ source /etc/profile.d/java.sh
$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)


Don't forget to change if there are people who set JAVA_HOME with tomcat. If you set it in / opt / java, you can solve it peacefully by changing the following symbolic link.

# cd /opt
java -> /usr/java/latest
# rm java
# ln -s /etc/alternatives/jre java
java -> /etc/alternatives/jre


Recommended Posts

Install OpenJDK8 with RPM
Install java with Homebrew
Install Ruby 3.0.0 with asdf
Install OpenJDK on macOS
Using Pair with OpenJDK
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Gradle with ubuntu16.04
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install openjdk11 on mac
Install OpenJDK 8 on mac
Install Composer with Docker
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
Install Java 8 (OpenJDK: Zulu Community) on macOS with Homebrew
Clogged with Express npm install
Network install CentOS 8 with Kickstart.
Install Java 7 with Homebrew (cask)
Install Oracle JDK 8 with Ansible
[Java development environment construction] Install OpenJDK 11 (Java 11) on macOS with Homebrew.
Install Ruby on MSYS2 with pacman
Install java with Ubuntu 16.04 based Docker
Install Java and Tomcat with Ansible
Install Java with zip on Windows
I can't install lombok with Gradle.
mysql2 fails to install with bundle install
How to install Adopt OpenJDK on Debian, Ubuntu with apt (-get)
Install ruby on Ubuntu 20.04 with rbenv
With CodeDeploy, Install doesn't end endlessly
Salesforce data loader released with Zulu OpenJDK 11
Install OpenJDK (Java) on the latest Ubuntu
Install Docker Desktop for Mac with Homebrew
Remove wine3.0 with ubuntu18.04LTS and install wine5.0 (winehq)
Install the package with npm install / yarn add
Install Java8 with Yum on Amazon Linux
Install Docker with WSL2 Memo ([Part 2] Docker introduction)