[JAVA] OpenJDK installation on CentOS 7

A memorandum when installing OpenJDK on CentOS7

OpenJDK installation

Method 1: Install with the yum command

It's the easiest because you just type the command. The installation destination is ``` / usr / lib / jrm /` ``. In addition, it is automatically registered in alternatives.

#java from yum repository-1.8.0-Search for openjdk packages
$ yum search java-1.8.0-openjdk
#Install OpenJDK runtime
$ sudo yum install java-1.8.0-openjdk
#Install OpenJDK development kit
$ sudo yum install java-1.8.0-openjdk-devel

Method 2: Install from rpm file

This is a method of downloading and installing the rpm file from a distribution site, etc., and is effective when installation is not possible with the yum command, such as when the Internet is not connected (of course, downloading is done from a terminal connected to the Internet). However, depending on the installation environment, it may be necessary to install dependent packages other than Java in advance.

The rpm file is distributed at pkgs.org, so download it and then install it in the following order. Like the yum command, it is automatically registered in alternatives.

$ sudo rpm -ivh java-1.8.0-openjdk-headless-1.8.0.171-7.b10.el7.x86_64.rpm
$ sudo rpm -ivh java-1.8.0-openjdk-1.8.0.171-7.b10.el7.x86_64.rpm
$ sudo rpm -ivh java-1.8.0-openjdk-devel-1.8.0.181-3.b13.el7_5.x86_64.rpm

Method 3: Install from binary file (Java 9 or later)

For Java 9 or later, install from the OpenJDK binary file.

The binary file is published on jdk.java.net, so download and unzip it.

After decompressing, move it to any folder and register it in alternatives.

#Unzip the tar file
$ tar xzvf openjdk-11_linux-x64_bin.tar.gz
#Move to any folder
$ mv jdk-11 /usr/lib/java/

#Register the command to be used in alternatives
$ alternatives --install /usr/bin/java java /usr/lib/java/jdk-11/bin/java 1
$ alternatives --install /usr/bin/javac javac /usr/lib/java/jdk-11/bin/javac 1

Switching the Java version to use

If multiple versions are installed, you can switch the Java version to use with alternatives.

** java command **

#Confirm alternatives of java command&Change to the setting to use jdk11 by specifying "3"
$ alternatives --config java

There are 3 programs'java'To provide.

Select command
-----------------------------------------------
   1           java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64/jre/bin/java)
*+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/bin/java)
   3           /usr/lib/java/jdk-11/bin/java

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

#Java version check
$ java -version
openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

** javac command **

#Check alternatives for javac command&Change to the setting to use jdk11 by specifying "2"
$ alternatives --config javac

There are 2 programs'javac'To provide.

Select command
-----------------------------------------------
*+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/bin/javac)
   2           /usr/lib/java/jdk-11/bin/javac

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

#Check javac version
$ javac -version
javac 11

Reference information

Recommended Posts

OpenJDK installation on CentOS 7
Docker installation on CentOS 6
Zabbix 5 installation on CentOS 8
OpenJDK installation
Enable Openjdk10 and maven on CentOS
OpenJDK 11 installation memo
OpenVPN on CentOS 8
First CentOS 8 installation
Maven on CentOS 7 tutorial
Install OpenJDK on macOS
HelloWorld using OpenJDK on CentOS8 after brain death
Use perltidy on CentOS 8
Install Golang on CentOS 8
Try OpenLiteSpeed on CentOS8
Install Neo4j 4.1.3 on centOS
OpenAM installation on VirtualBox
Tomcat v8 on CentOS7
Install Vertica 10.0 on CentOS 6.10
Use mod_auth_cas on CentOS 8
Install nginx on centOS7
Install Python 3 on CentOS 7
Install kuromoji on CentOS7
Use bat on Centos.
Jetty v8 on CentOS7
Install Mattermost on CentOS 7
Install PostGIS 2.5.5 on CentOS7
Install jpndistrict on CentOS 7
Install openjdk11 on mac
Install Redmine 4.1.1 on CentOS 7
Install OpenJDK 8 on mac
Smokeping Install on CentOS7
Install PostgreSQL 13 on CentOS 7.5
Docker installation on WSL2
Installation of Oracle Database XE on CentOS7 (t2.micro instance)
Try RabbitMQ + PHP on CentOS
Install OpenJDK7 (JAVA) on ubuntu 14.04
Make exFat available on CentOS 7
Manually build OpenJDK on Windows
Install OpenFOAM v2006 on CentOS
Ruby installation on WSL2 + Ubuntu 20.04
Install Jenkins on Docker's CentOS
Install Apache on CentOS on VirtualBox
Introducing Let's Encrypt on CentOS 7
Java version change on CentOS
Install Ruby 2.7 on CentOS 7 (SCL)
Perform log rotation on centos
Install openjdk8 on Docker image (Debian)
Try DPDK20 SDK on CentOS7 â‘ Install
How to deploy Laravel on CentOS 7
Install Ruby 2.5 on CentOS 7 using SCL
Install Java Open JDK 8 on CentOS 7
Try putting CentOS 8 on Raspberry Pi 3
WordPress with Docker Compose on CentOS 8
Upgrade from MYSQL5.7 to 8.0 on CentOS 6.7
How to install MariaDB 10.4 on CentOS 8
Install apache 2.4.46 from source on CentOS7
Steps to install MySQL 8 on CentOS 8
Use the iostat command on CentOS 8
Elmer / Ice installation (Ubuntu on WSL)
I tried installing CentOS 8 on ESXi 6.7
Steps to install devtoolset-6 on CentOS 7