执行cv
时会抛出以下错误:
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
答案 0 :(得分:2)
从下面的https://ubuntuforums.org/showthread.php?t=2374686报告了安装oracle-java8-installer
的ansible playbook,它实现了上述答案中所示的解决方法(据说也来自同一个来源)。
---
- 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"
答案 1 :(得分:0)
迟到的答案,但我刚刚发现了另一种安装java而没有任何问题的方法。
只需安装openjdk 8
apt-get install openjdk-8-jre-headless
然后通过
进行测试java -version
答案 2 :(得分:0)
ppa非常棒,我感谢其中所做的工作。最近,oracle更改了路径,需要更新ppa,直到再次起作用。同时,我发现this workaround from the ubuntu论坛对安装jdk8很有帮助(我删除了docker特定的东西):
### 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