yum centos container mounting JDK installation environment DOCKER CENTOS, TOMCAT, JDK other custom related (DOCKERFILE) Mirror

1, yum command to install jdk

Select the version installed

yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

Or the following command to install all the files jdk1.8.0

yum install -y java-1.8.0-openjdk*
yum install -y java-1.8.0-openjdk.x86_64

2, see JDK installation was successful

# java -version

[root@1c164311bb8b /]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

3, configure the environment variables

JDK default installation path / usr / lib / jvm

[root@1c164311bb8b jvm]# pwd
/usr/lib/jvm
[root@1c164311bb8b jvm]#
[root@1c164311bb8b jvm]# ll
total 0
drwxr-xr-x. 3 root root 17 Jul 30 05:48 java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
lrwxrwxrwx. 1 root root 21 Jul 30 05:48 jre -> /etc/alternatives/jre
lrwxrwxrwx. 1 root root 27 Jul 30 05:48 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx. 1 root root 35 Jul 30 05:48 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx. 1 root root 51 Jul 30 05:48 jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 -> java-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64/jre
lrwxrwxrwx. 1 root root 29 Jul 30 05:48 jre-openjdk -> /etc/alternatives/jre_openjdk
[root@1c164311bb8b jvm]#

In the / etc / profile file add the following command

# set java environment  
JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64
PATH=$PATH:$JAVA_HOME/bin  
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar  
export JAVA_HOME  CLASSPATH  PATH 

Save and close the file profile, execute the following command to take effect

source  /etc/profile

4, when writing Dockerfile files, only variable to define a container (third portion may be omitted)

ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64

 

Reference blog:

DOCKER installation CENTOS, TOMCAT, JDK other custom related (DOCKERFILE) Mirror

Installation and Configuration CentOS 7 yum JDK

https://blog.csdn.net/github_38336924/article/details/82221258

Guess you like

Origin www.cnblogs.com/djlsunshine/p/11269746.html