在Docker Debian 10(Buster)上安装Oracle JDK8

时间:2020-09-14 18:55:05

标签: java docker version

我想在Docker Debian 10(Buster)容器上安装Oracle JDK8。默认容器Java是:

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

JAVA_HOME在哪里

/usr/local/openjdk-8

在Stack和网络上的众多示例之后,我执行了以下操作,但均未成功:

通过Dockerfile构建来安装映像:

FROM tomcat:8.5
MAINTAINER joco

# set up tomcat app
COPY ROOT.war /usr/local/tomcat/webapps/
COPY /libs/* /usr/local/tomcat/lib/
COPY server.xml /usr/local/tomcat/conf

# install Oracle jdk8
COPY jdk-8u202-linux-x64.tar.gz /usr/local/jdk-8u202-linux-x64.tar.gz
RUN tar zxvf /usr/local/jdk-8u202-linux-x64.tar.gz -C /usr/local/
ENV JAVA_HOME /usr/local/jdk1.8.0_202
RUN rm /usr/local/jdk-8u202-linux-x64.tar.gz


EXPOSE 8080

解压缩文件并设置JAVA_HOME环境变量:

JAVA_HOME = /usr/local/jdk1.8.0_202

但是java -version仍然指向

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

此外

# update-alternatives --list java
update-alternatives: error: no alternatives for java

如何将Java版本设置为Oracle JDK?

我评论过的其他帖子(不全面)

0 个答案:

没有答案