12

I am trying to install java 8 through oracle-java8-installer on a debian:jessie docker container. The following is my Dockerfile:

FROM debian:jessie

ENV JAVA_VERSION 1.8.0

RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN echo "debconf shared/accepted-oracle-license-v1-1 select true" | /usr/bin/debconf-set-selections
RUN apt-get update
RUN apt-get install -y --force-yes vim
RUN apt-get install -y --force-yes oracle-java8-installer

Yet this gives:

Connecting to download.oracle.com (download.oracle.com)|23.63.224.171|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-01-17 12:31:05 ERROR 404: Not Found.

download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get install -y --force-yes oracle-java8-installer' returned a non-zero code: 100

I have found many similar issues described online, but none of the proposed solutions worked for me. Any idea?

Jacopo Lanzoni
  • 1,264
  • 2
  • 11
  • 25
  • I have no relevant experience with docker, but I use Debian for some time and it looks not good to me that you are instlling a package from an ubuntu repository on Debian. When I need to install Oracle JDK I download it from the Oracle site and create a .deb file with java-package as described [here](https://wiki.debian.org/JavaPackage). – Andriy Simonov Jan 17 '18 at 13:36

5 Answers5

9

Found the solution on https://hub.docker.com/r/anapsix/docker-oracle-java8/~/dockerfile/:

## JAVA INSTALLATION
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" > /etc/apt/sources.list.d/webupd8team-java-trusty.list
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends oracle-java8-installer && apt-get clean all

The "secret sauce" you were looking for is the first line:

RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
Stephen Quan
  • 21,481
  • 4
  • 88
  • 75
  • 1
    The command '/bin/sh -c apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends oracle-java8-installer && apt-get clean all' returned a non-zero code: 100 – ses Jul 18 '19 at 16:05
7

Re to donhector's response and your question: you need to replace the strings in the installer file, instead of yours last command:

apt-get install -y --force-yes oracle-java8-installer

run these commands:

apt-get -y install oracle-java8-installer || true
cd /var/lib/dpkg/info

sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' oracle-java8-installer.*
sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' oracle-java8-installer.*
sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' oracle-java8-installer.*
sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' oracle-java8-installer.*

apt-get install -f -y
apt-get install -y oracle-java8-set-default

I have them in a separate script and run it as

RUN /bin/sh /path/to/script.sh

or you can run them directly from your Dockerfile, that's up to you.

Martin Šuráb
  • 167
  • 2
  • 5
5

You are installing from the webupd8 PPA repo. If you notice, the Java 8 package in that repo points to Java 8 version 151. That package pulls the binary for 151 from the Oracle servers (since Java Oracle licence does not allow anyone else hosting the binaries). Oracle released version 161 a couple days back and apparently moved or removed 151 from their servers. So basically the package in the webupd8 PPA repo is trying to download the 151 binary which no longer exists at the location that the webupd8 package expects it (hence the 404 you got). The webupd8 PPA repo maintainer will have to release a new package pointing to the new 161 binaries from Oracle. Docker or Debian don't play any role in the issue, it is just basically a broken link issue.

Until then you could apply a "workaround" like the one mentioned here: JDK 8 is NOT installed - ERROR 404: Not Found

Here's the list of Java packages in the webupd8 repo:

https://launchpad.net/~webupd8team/+archive/ubuntu/java/+packages

donhector
  • 875
  • 1
  • 10
  • 21
  • Linked "JDK 8 is NOT installed" answer was very helpful – Cumulo Nimbus Jan 17 '18 at 20:53
  • Thanks for clear explanation @donhector. I get the idea of the workaround but I cannot understand how to implement it. Where should I add the following? RUN apt-get --download-only -y --force-yes install oracle-java8-installer RUN sed -i ... /var/cache/apt/archives/oracle-java8-installer* ... – Jacopo Lanzoni Jan 18 '18 at 08:33
2

See dpkg oracle Jdk error while installing cassandra in Ubuntu 16.04. This issue is occurring for everyone using install scripts of any kind.

DoctorPangloss
  • 2,994
  • 1
  • 18
  • 22
1

** Java 11:

RUN apt-get install wget java-common gnupg2 -y
RUN echo "oracle-java11-installer shared/accepted-oracle-license-v1-2 select true" | debconf-set-selections
RUN echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" | tee /etc/apt/sources.list.d/linuxuprising-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends oracle-java11-installer && apt-get clean all
rodrigoclp
  • 11
  • 2