5

The following error is thrown when you execute sudo apt-get install oracle-java8-installer:

Location: http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508340360_7be4aa21e145dd26bda475add7c27ada [following]
                    --2017-10-18 08:24:00--  http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508340360_7be4aa21e145dd26bda475add7c27ada
                    Reusing existing connection to 2.2.0.1:8080.
                    Proxy request sent, awaiting response... 404 Not Found

A temporarily workaround is:

cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*
Josh Kelley
  • 56,064
  • 19
  • 146
  • 246
  • 1
    Worth keeping an eye on this too: https://ubuntuforums.org/showthread.php?t=2374686 – Ben Smith Oct 18 '17 at 17:01
  • What is your exact OS Debian or Ubuntu? What is the exact release? – GAD3R Oct 19 '17 at 17:08
  • This is for both Ubuntu trusty (14.04) and xeniel (16.x) releases. – Zile Rehman Oct 25 '17 at 16:14
  • This problem should no longer exists. You can use the following commands. `sudo add-apt-repository -y ppa:webupd8team/java && sudo apt-get update` `sudo apt-get install oracle-java8-installer` – Zile Rehman Jan 24 '18 at 03:12
  • Seems like the problem is occurring again! – Zile Rehman Apr 19 '18 at 16:44
  • The issue is resolved now. They recently updated it. sudo add-apt-repository -y ppa:webupd8team/java && sudo apt-get update sudo apt-get install oracle-java8-installer should work fine now. Here is more info - https://launchpad.net/~webupd8team/+archive/ubuntu/java – Ajay Kumar Oct 24 '18 at 06:16

3 Answers3

2

From https://ubuntuforums.org/showthread.php?t=2374686 below is reported the ansible playbook to install oracle-java8-installer implementing the workaround illustrated in the above answer (also coming from the same source, supposedly).

---

- name: Add Oracle Java webupd PPA
  apt_repository:
    repo: "ppa:webupd8team/java"


- name: Accept Java licence
  debconf:
    name: "oracle-java{{ java.version }}-installer"
    question: shared/accepted-oracle-license-v1-1
    vtype: select
    value: "true"


# - name: Install Oracle Java
#   apt:
#     name: "{{ item }}"
#     update_cache: yes
#     state: latest
#     force: yes
#   with_items:
#     - "oracle-java{{ java.version }}-installer"
#     - "oracle-java{{ java.version }}-set-default"


# Temporary fix for webupd8team installer issue
- name: Install Oracle Java
  block:
    - apt:
        name: "{{ item }}"
        update_cache: yes
        state: latest
        force: yes
      with_items:
        - "oracle-java{{ java.version }}-installer"
        - "oracle-java{{ java.version }}-set-default"
  rescue:
    - shell: cd /var/lib/dpkg/info && sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
    - shell: cd /var/lib/dpkg/info && sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/|' oracle-java8-installer.*
    - shell: cd /var/lib/dpkg/info && sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
    - shell: cd /var/lib/dpkg/info && sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*
  always:
    - apt:
        name: "{{ item }}"
      with_items:
        - "oracle-java{{ java.version }}-installer"
        - "oracle-java{{ java.version }}-set-default"
spac
  • 346
  • 1
  • 10
  • As of today, this has stopped working for me. The package is trying to download https://edelivery.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz which isn't matched (anymore?) by the `sed` commands. – giorgiosironi Jan 22 '18 at 11:15
  • https://ubuntuforums.org/showthread.php?t=2374686&page=5&p=13732563#post13732563 has an updated version of the `sed` commands that I am testing. – giorgiosironi Jan 22 '18 at 11:18
  • Confirmed the updated version works as of today: `java version "1.8.0_162"` – giorgiosironi Jan 22 '18 at 11:20
  • @giorgiosironi can you edit the answer with the correct see lines that worked for you? – spac Jan 23 '18 at 13:44
  • 1
    A release of `java8-oracle-installer` has been made yesterday that makes the workaround unnecessary (for now): `8u161-1~webupd8~0` at https://launchpad.net/~webupd8team/+archive/ubuntu/java – giorgiosironi Jan 23 '18 at 13:58
  • Edited, waiting in review. – giorgiosironi Jan 23 '18 at 14:01
0

Late answer but I just found out another way to install java without any problems.

Just install openjdk 8

apt-get install openjdk-8-jre-headless

then test it through

java -version

See also: https://www.youtube.com/watch?v=fdB5dhPXiXc

  • 1
    But you are installing the openJDK version of Java not the oracle one. See also [Technically what is the main difference between Oracle JDK and Open JDK?](https://stackoverflow.com/questions/22358071/differences-between-oracle-jdk-and-open-jdk-and-garbage-collection) – Murmel Jan 20 '18 at 18:27
  • This is the debian for open JDK java. Issue was with oracle Java 8 which no longer exists. – Zile Rehman Jan 24 '18 at 03:05
0

The ppa is great and I appreciate the work put into it. Recently oracle changed the paths and the ppa needs to be updated until it works again. In the mean time I found this workaround from the ubuntu forum helpful to install jdk8 (I removed the docker specific stuff):

### workaround to install oracle jdk8 until ppa will be updated
# install java via wget site oficial oracle
# note: JAVA_FILE_TAR, JAVA_URL_DOWNLOAD and JAVA_DIR  must be entered manually
export JAVA_FILE_TAR=jdk-8u191-linux-x64.tar.gz
export JAVA_URL_DOWNLOAD="http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/${JAVA_FILE_TAR}"
export JAVA_DIR=jdk1.8.0_191
# download and extract tar
cd /opt
wget -q --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JAVA_URL_DOWNLOAD}
tar zxvf ${JAVA_FILE_TAR} && pwd && ls -la
# set default java
update-alternatives --install /usr/bin/java java /opt/${JAVA_DIR}/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/${JAVA_DIR}/bin/javac 1
update-alternatives --install /usr/bin/jar jar /opt/${JAVA_DIR}/bin/jar 1
# set temp env vars
export JAVA_HOME=/opt/${JAVA_DIR}
export PATH=$PATH:/opt/${JAVA_DIR}/bin:/opt/${JAVA_DIR}/jre/bin
echo "export JAVA_HOME=/opt/${JAVA_DIR}" >> /etc/environment
echo "export PATH=$PATH:/opt/${JAVA_DIR}/bin:/opt/${JAVA_DIR}/jre/bin" >> /etc/environment
aboettcher
  • 81
  • 6