oracle-java8-installer Webupd8 PPA 404 Not Found - java

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.*

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"

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

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

Related

Install java 8 (jdk 1.8) using "vagrant up" not working on debian

When I am Running My Vagrantfile with its shell, I'm struggle with Java 8 install with this exact same error :
StackOverflow - jdk-8-is-not-installed-error-404-not-found
In order to fix that error, I added those lines :
sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo 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/|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
I have in my Shell this block for java section:
# /*======================
# = JAVA =
# ======================*/
# https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8
sudo apt-get install -y software-properties-common
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
sudo apt-get update
# Silent !! Sshh !
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
# see https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found
# Still not work
sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo 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/|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y oracle-java8-set-default
The weird thing is : Those lines taken one by one via SSH when the box is started and you can install Java, it Works. But it's not working when I provision for the first time my vagrant box.
Is the problem comes from sed or another command ? I suppose it's the sed's command but don't know how to fix it, because it's working if I paste them via SSH.
I want to make this work without any manual interventions.
You can test my VM using this github repo (V2) :
VagrantFile + shells
How can I make this work using vagrant up ?
EDIT :
I've tested it on Vagrant 2.0 and virtualBox 5.6
Also tested with vagrant 1.7 and virtualBox 5.1
I'm putting this in just in case anyone is fine with Debians basic version, but has missed it. I think it should already be installed on anything but the most bare-bones systems.
To get openJDK working, which is the version offered in Debians standard repos, you would just need to use
apt-get install -y openjdk-8-jdk
There are other debug and docs packages as well.
Debian also provide a package in the contrib repos called java-package which converts the source tarball from the Oracle site (you have to get it yourself to OK the terms and conditions), and creates a deb from it. Unfortunately there doesn't seem to be a way to directly presume yes to the questions asked, so it would need an expect script or something.
config.vm.provision "shell", inline: <<-SHELL
# add contrib repos into source files.
mv /etc/apt/sources.list /etc/apt/sources.bk
sed -r ‘s/stretch([^ ]*) main$/& contrib/‘ /etc/apt/sources.bk | sudo tee /etc/apt/sources.list
# vi -c ':%s/stretch\([^ ]*\) main$/& contrib/g' /etc/apt/sources.list -c 'wq'
apt-get update
apt-get install -y java-package java-common expect
# some `expect` needed magic here
sudo -u vagrant fakeroot make-jpkg /vagrant/jdk-8*
dpkg -i oracle-java8*
SHELL
In terms of the interactions I get using make-jpkg, this script works (from the command line)
expect -c '
set timeout -1
spawn fakeroot make-jpkg /vagrant/jdk-8u162-linux-x64.tar.gz
expect "Is this correct \\\[Y/n\\\]: $" { send "Y\r" }
expect "Press \\\[Return\\\] to continue: " { send "\r" }
expect "*Press \\\[Return\\\] to continue or Ctrl-C to abort." { send "\r" }
expect eof { exit 0 }
'
but could probably be done other ways.
So almost an answer, but may get you a bit closer.
Sorry for my late answer. Another option is to mount a drive and install the oracle rpm package silently.
Create directory and put there your Vagrantfile. This the root of your project. (./)
Vagrantfile
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/centos-7.4"
config.vm.boot_timeout = 240
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# View the documentation for the provider you are using for more
# information on available options.
config.vm.provider "virtualbox" do |vb|
# Enable the Host I/O cache for more performance
vb.customize [
"storagectl", :id,
"--name", "SATA Controller",
"--hostiocache", "on"
]
vb.auto_nat_dns_proxy = false
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"
vb.customize ["modifyvm", :id, "--memory", 4096]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.cpus = 4
end
# Synced folders are configured within your Vagrantfile using the config.vm.synced_folder method.
# Vagrant shares by default the root directory of (./) with guest on /vagrant
config.vm.synced_folder ".", "/vagrant", disabled: true
# Synced folder is set as read-only for guest machine. You can configure the files on the host machine.
# For more mount options check: http://manpages.ubuntu.com/manpages/precise/man8/mount.vboxsf.8.html
config.vm.synced_folder "./installfiles", "/installfiles",
owner: "vagrant", group: "vagrant", mount_options: ["ro"]
# Bootstrap shell scripts.
config.vm.provision "shell", path: "./bootstrap/setup.sh"
config.vm.post_up_message = "Finsihed provisioning!\n" \
"Type \"vagrant ssh\" to get started"
end
Create another directory named bootstrap from the root of your project. Create an empty file called setup.sh, put the content below in the setup.sh file. The file path will be ./bootstrap/setup.sh
setup.sh
#!/usr/bin/env bash
echo "installing Java 8 64 bit"
sudo rpm -i /installfiles/java8/jdk-8u144-linux-x64.rpm
unzip /installfiles/java8/jce_policy-8.zip -d /tmp
sudo cp -f /tmp/UnlimitedJCEPolicyJDK8/* $JAVA_HOME/lib/security/
Go to the oracle website download the correct 32 or 64 bit rpm linux package. Versions available on the oracle website might change. For this example i downloaded the jdk-8u144-linux-x64.rpm package. I also downloaded the unlimited encryption strength policy from the oracle website, name of the file is: jce_policy-8.zip.
Create two directories from the root of your project named installfiles/java8. Place the downloaded files in there. The files path will be: ./installfiles/java8/jdk-8u144-linux-x64.rpm and ./installfiles/java8/jce_policy-8.zip
Run the command vagrant up. On your host machine the directory ./installfiles will be synchronised with your virtualbox guest machine on the path /installfiles. During the provisioning state of vagrant java-8 will be installed automatically. Keep in mind that the rpm package manager comes out of the box with Red Hat distros. But it is also possible to install rpm packages on debian distros.
The following snippet fixes the silent install of java from webupd8team repo for Debian distribution
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:webupd8team/java
sudo bash -c "echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list"
sudo bash -c "echo deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main >> /etc/apt/sources.list.d/webupd8team-java.list"
sudo bash -c "echo deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main >> /etc/apt/sources.list.d/webupd8team-java.list"
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo apt-get -y upgrade
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selectionssudo
sudo apt-get -y install oracle-java8-installer oracle-java8-set-default
As of today, it installs the following
vagrant#debian-8:~$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

Installing Java8 in Dockerfile [duplicate]

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?
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
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.
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
See dpkg oracle Jdk error while installing cassandra in Ubuntu 16.04. This issue is occurring for everyone using install scripts of any kind.
** 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

Java Install Fails On Ubuntu 14

I am trying installl jave 8 (jre/jdk) in my ubuntu 14.0.4
sudo apt-get update
sudo apt-get install oracle-java8-installer
I get below error
Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc
Downloading Oracle Java 8...
--2017-10-17 16:42:09-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 64.78.224.186, 64.78.224.185
Connecting to download.oracle.com (download.oracle.com)|64.78.224.186|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz [following]
--2017-10-17 16:42:10-- https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.217.152.181, 2600:141b:13:28c::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.217.152.181|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508276650_49e5615c0aa8584dd72b809fbec787eb [following]
--2017-10-17 16:42:10-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508276650_49e5615c0aa8584dd72b809fbec787eb
Connecting to download.oracle.com (download.oracle.com)|64.78.224.186|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-10-17 16:42:11 ERROR 404: Not Found.
download failed
Oracle JDK 8 is NOT installed.
looks like it is looking for 8u144 which is not available.
How can i make it look for 8u151?
I did this
sudo add-apt-repository ppa:webupd8team/java -> no luck
This has been an issue as of today (we hit the webupd8team ppa once a day for oracle-8-installer). From past experience it's probably due to the fact that Oracle released their quarterly Java updates overnight (8u151 and 8u152), and moved or deleted 8u144. If you dig into the ppa you'll see it only references 8u144.
I'm not that knowledgable on how the webupd8team ppa is managed, but presumably it requires some manual intervention on the maintainer's part to fix the issue.
I am trying out this solution:
https://ubuntuforums.org/showthread.php?t=2374686 -> No luck at the moment
What works for me, I tried manually with this:
Create a folder to put JDK
mkdir /opt/jdk
cd /opt
Download the latest JDK:
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/jdk-8u152-linux-x64.tar.gz
Extract it
tar -zxf jdk-8u152-linux-x64.tar.gz -C /opt/jdk
Set it as default
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_152/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_152/bin/javac 100
"As a temporary work around":
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.*
And then try installing JAVA again. From this ubuntuforums thread.
After downloading the Java Oracle tar ball to your home directory, you will need to run the following script to automatically install Java 8.
#!/bin/bash -e
JAVA_VER=$(javadd -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*"/\1\2/p;')
if [ "${JAVA_VER}" != "18" ]; then
file_name="jdk-8u172-linux-x64.tar.gz"
cd ~
sudo mkdir -p /opt/jdk
sudo tar -zxf ~/${file_name} -C /opt/jdk
sudo apt-get remove -y --purge openjdk-\* || true
cd /opt/jdk/jdk1.8.0_172/bin
for j in `ls j*`; do
sudo update-alternatives --force --install /usr/bin/${j} ${j} /opt/jdk/jdk1.8.0_172/bin/${j} 100
done
sudo update-alternatives --display java
fi

purge doesn't uninstall java 6?

I'm using Vagrant to simulate a network for a distributed system project. I'm using this file provision.sh in order to provision each machine in the cluster:
sudo apt-get update
sudo apt-get install -y openjdk-7-jdk
sudo apt-get purge -y openjdk-6-jre
sudo apt-get purge -y openjdk-6-jre-lib
sudo apt-get install -y maven
echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386" >> /home/vagrant/.profile
echo "export PATH=$JAVA_HOME/bin:$PATH" >> /home/vagrant/.profile
mvn clean -f /vagrant/RaftFS/pom.xml
mvn package -f /vagrant/RaftFS/pom.xml
sudo mv /vagrant/RaftFS/target/RaftFS-1.0-SNAPSHOT-jar-with-dependencies.jar /vagrant/
sudo cp /vagrant/RaftFS/servers.yaml /vagrant/
But when I access to the VM and I run java -version it says that the version 6 is still installed! How is that possible? As suggested by #ydaetskcoR if I execute env | grep JAVA_HOME it returns JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 ...so I don't get why it says that the java version is 6
Just for completeness, this is the Vagrant file:
# -*- mode: ruby -*-
# # vi: set ft=ruby :
# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"
# Require YAML module
require 'yaml'
# Read YAML file with box details
servers = YAML.load_file('RaftFS/servers.yaml')
# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Iterate through entries in YAML file
servers.each do |key,value|
config.vm.define key do |srv|
srv.vm.box = value['box']
srv.vm.network "private_network", ip: value['ip']
srv.vm.hostname=key
srv.vm.synced_folder ".", "/vagrant" , disabled:true
srv.vm.synced_folder "ServersFS/"+key+"/", "/vagrant/ServersFS" , create: true
srv.vm.synced_folder "./RaftFS", "/vagrant/RaftFS"
srv.vm.provision :shell, path: "provision.sh"
srv.vm.provider :virtualbox do |vb|
vb.name = key
vb.memory = value['ram']
end
end
end
end
and this is servers.yaml file:
hal9000:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.101
ftpPort: 8080
skynet:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.102
ftpPort: 8081
jarvis:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.103
ftpPort: 8083
After installing new Java version, you must to inform your system where your Oracle Java JDK/JRE is located and with version must be used as default. This will tell the system that the new Oracle Java version is available for use.
For this you must use "update-alternatives", something like this:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_20/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_20/bin/javac" 1
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_20/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_20/bin/javac
Change paths to your openjdk-7-jdk files
I found out by myself the answer to my problem: I had simply to update the system's alternatives with these two commands:
sudo apt-get install icedtea-7-plugin
sudo update-java-alternatives -s java-1.7.0-openjdk-i386
The first one is necessary since this error would be thrown otherwise:
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
Now if I run java -version the correct version (7) is returned.

Error thrown in update-alternatives

I am trying to install jdk for 32-bit OS. Followed the below steps,
wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com" http://download.oracle.com/otn-pub/java/jdk/6u38-b05/jdk-6u38-linux-i586.bin
chmod u+x jdk-6u34-linux-i586.bin
./jdk-6u34-linux-i586.bin
mkdir -p /usr/lib/jvm /usr/bin/java /usr/bin/javac /usr/bin/javaws
mv jdk1.6.0_3./usr/lib/jvm/`
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_38/bin/java" 1
update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_38/bin/javac" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_38/bin/javaws" 1
but while running cmd 6 i am getting below error. Any help would be appreciated.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jdk1.6.0_38/bin/java because link group java is broken.
update-alternatives: warning: not replacing /usr/bin/java with a link.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib/jvm/jdk1.6.0_38/bin/javac because link group javac is broken.
update-alternatives: warning: not replacing /usr/bin/javac with a link.
update-alternatives: error: alternative path /usr/lib/jvm/jre1.6.0_38/bin/javaws doesn't exist.
if you need to install java in Ubuntu, you can try using following command and you will get oracle-java-installer in your synaptic package manager, click it and install it.
sudo add-apt-repository ppa:webupd8team/java
Else try following steps
$ wget http://download.oracle.com/otn-pub/java/jdk/6u34-b04/jre-6u34-linux-i586.bin
$ chmod u+x jre-6u34-linux-i586.bin
$ ./jre-6u34-linux-i586.bin
$ sudo mkdir -p /usr/lib/jvm
$ sudo mv jre1.6.0_34 /usr/lib/jvm/
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_34/bin/java" 1
$ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jre1.6.0_34/lib/i386/libnpjp2.so" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_34/bin/javaws" 1
The issue is that you have created a folder named "java" in /usr/bin . Remove the folder from /usr/bin and run the command again.
Instead of Step 4 :
4. mkdir -p /usr/lib/jvm /usr/bin/java /usr/bin/javac /usr/bin/javaws
Just use
$mkdir -p /usr/lib/jvm
and make sure that you are moving the files to usr/lib/jvm , for that use
$mv -v jre1.6.0_34 /usr/lib/jvm/
so that you can see the details and after installation change the configuration of java and javaws by :
$update-alternatives --config java
select from the option
similarly ,
$update-alternatives --config javaws
this should work if you have already another java installed
Remove folder java from /usr/bin and try again

Categories

Resources