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)
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-1.8.0.171-7.b10.el7.x86_64.rpm * java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64.rpm
$ wget 'http://mirror.centos.org/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-headless-1.8.0.171-7.b10.el7.x86_64.rpm'
$ wget 'http://mirror.centos.org/centos/7/updates/x86_64/Packages/java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64.rpm'
Even if you install it as it is, an error will occur, so update the following
$ yum update copy-jdk-configs
$ yum update nss
Since headless is the main, let's install headless first.
$ rpm -ivh java-1.8.0-openjdk-headless-1.8.0.171-7.b10.el7.x86_64.rpm
$ rpm -ivh java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64.rpm
The installation destination is / usr / lib / jvm. It's completely different from the Oracle JDK.
/usr/lib/jvm
drwxr-xr-x 3 root root 16 May 9 22:55 java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64
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-1.8.0.171-7.b10.el7.x86_64 -> java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64/jre
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-1.8.0.171-7.b10.el7.x86_64/jre/bin/java)
Press Enter to select the current[+]Or enter the selection number:
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