Procedure for manually installing Java (jdk1.8) on Linux (CentOS7)

The materials created on 2017/06/03 will be uploaded.

An easy way to install Java on Linux (CentOS7) is to use the yum command or rpm command, but here we will show you how to install it manually.

1. Log in to CentOS7 and switch to the root user.

$ su -
#

2. Download "jdk-8u131-linux-x64.tar.gz" from the Oracle web page.

# curl -OL --header "Cookie: oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz"

(The URL of the link destination may have changed?) (You may download it from your browser instead of using the command.)

3. Unzip "jdk-8u131-linux-x64.tar.gz".

# tar xvzf ./jdk-8u131-linux-x64.tar.gz

("Jdk1.8.0_131" is created.)

4. Copy (move) "jdk1.8.0_131" under / opt "

# mv ./jdk1.8.0_131 /opt

5. Create a symbolic link to absorb path changes due to future version upgrades of jdk.

# ln -s /opt/jdk1.8.0_131 /opt/java

6. Exit the root user and return to the logged-in user.

# exit
$

7. Create a Java environment file ".java.env".

shell:.java.env


export JAVA_HOME=/opt/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.

8. Read the created java environment file.

$ source .java.env

9. Check the version of jdk installed by Java command.

$ java –version
(The following is displayed.)
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

10. Add the following to ".bash_profile" in the user's home directory so that environment variables are set at login.

.bash_profile


・ ・ ・ ・ ・ ・ ・ ・
source .java.env ← Add this line

[Environment variables]

This time, ".java.env" was created and the environment was set with the source command, but if the following files are placed under the "/etc/profile.d" directory, the environment variables will be set at login.

shell:./etc/profile.d/java.sh


#!/bin/sh
export JAVA_HOME=/opt/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.

that's all

Recommended Posts

Procedure for manually installing Java (jdk1.8) on Linux (CentOS7)
Install java (Oracle JDK14) on CentOS7
[Go] Procedure for installing Go on WSL2
Teamviewer for Linux installation procedure (CentOS)
Procedure for installing Xenomai on RaspberryPi 3 model B + Part 1
Install the JDK on Linux
Notes on installing Python on CentOS
Install oracle java8 on amazon linux2
Try installing OpenAM on Amazon Linux
[Linux] I installed CentOS on VirtualBox
pykintone on Windows Subsystem for Linux
Until you install Apache and Tomcat on Linux (CentOS) and deploy Java apps
Procedure for building a kube environment on amazon linux2 (aws) ~ (with bonus)
Find out where the java entity is on Linux (CentOS this time)
Notes for installing Sublime Text on Ubuntu
[Note] Procedures for installing Ubuntu on Windows 10
WSL2 (Windows Subsystem for Linux) installation procedure
Install Mecab on Linux (CentOS) with brew
How to update security on CentOS Linux 8
Disable IPv6 on network interface on CentOS Linux 8
The easiest procedure and explanation for installing Oracle Linux 8.3 (DB construction first part)
[Linux] Review of commands for deploying on AWS
Make a bot for Skype on EC2 (CentOS)
[Linux] When "| (pipe)" cannot be hit on CentOS7
How to build Java environment on Ubuntu (Linux)
Installing TensorFlow on Windows Easy for Python beginners