15

I've installed oracle JDK-8 on ubuntu 14.04 manually. but whenever I want to install a package that needs jdk8, apt-get tries to install jdk 8 again. my country is restricted so oracle server won't allow me to download jdk8.

$java -version

java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

and the results of apt-get are:

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)

with this error, apt-get won't finish the installation.

tk_
  • 16,415
  • 8
  • 80
  • 90
batroudoroch
  • 153
  • 1
  • 1
  • 6

7 Answers7

13

oracle-java8-installer is not able to download file. So downlaod it manually from Oracle site and put into folder /var/cache/oracle-jdk8-installer/. And try to install oracle-java8-installer again. This solved the problem for me.

Step by step:

  • Check what file oracle-java8-installer is not able to download. You can see it in installation log. Let's suppose it's jdk-8u111-linux-x64.tar.gz
  • Google it jdk-8u111-linux-x64.tar.gz and you'll find exact page on Oracle site where to download it from. For our example it's http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  • Download jdk-8u111-linux-x64.tar.gz file and put in into folder /var/cache/oracle-jdk8-installer/.
  • And try to install oracle-jdk8-installer again: sudo apt-get install oracle-java8-installer Installation should finish successfully.
Viktor Kruglikov
  • 519
  • 6
  • 16
5

Try this,

First update the apt-get repos

$ sudo apt-get update

Add the java 8 repo to apt-get

$ sudo add-apt-repository ppa:webupd8team/java

Again update the apt-get repo

$ sudo apt-get update

Finally install java 8

$ sudo apt-get install oracle-java8-installer

References:

tk_
  • 16,415
  • 8
  • 80
  • 90
  • @mdeora which step is failing and what is the error? – tk_ Oct 17 '18 at 23:25
  • Basically the ppa is not updated with the new version of Java8 so current version is giving 404 error on installing. – mdeora Oct 18 '18 at 05:08
  • By right, above answer should work. Please find the references. – tk_ Oct 18 '18 at 05:29
  • See this link, the first answer is what you need to do, My setup is ubuntu 16.04, you need to replace 8u181 with 8u191 and accordingly the hashes and urls. https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found – mdeora Oct 18 '18 at 09:33
  • 1
    Among all the above answers, as well as, among many other ways I found on the internet only the steps described in this answer worked for me - Running Ubuntu 18.04 - Thank you. – dimcode Oct 18 '18 at 13:27
  • there are no issues with the steps, its just that the java bin downloaded by "ppa:webupd8team/java" for java 8 is not updated. – mdeora Oct 19 '18 at 11:55
  • in the fourth step, I get this. ***Reading package lists... Done Building dependency tree Reading state information... Done Package oracle-java8-installer is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'oracle-java8-installer' has no installation candidate*** – Amila Senadheera Jun 02 '20 at 17:05
4

the first step:

sudo apt-get remove oracle-java8-installer

to clean up the failure installation of java8 perviously.

the second step:

sudo apt-get install oracle-java8-installer

to reinstall Java8

Ivan Lee
  • 3,420
  • 4
  • 30
  • 45
2

I suspect you've installed Oracle JDK8 using the archive, extracting to your own folder. It's probably the case that Ubuntu doesn't know that you've installed Java as the system Java and so is raising the error.

To be honest, I'm not sure how you go about installing it for system wide use but this page may provide some pointers. Installing Open JDK might be the better option, but an option is also given here, and this answer might also help.

Community
  • 1
  • 1
Tony Weddle
  • 2,081
  • 1
  • 11
  • 15
  • I found peace with oracle server. and now everything is OK. but surely the problem was with the manual installation. – batroudoroch Sep 26 '15 at 07:06
1

One of the possible reasons and solution could be, that the version of the java package is updated with the possible vulnerability patch fix, and that needs to be updated in the PPA. I faced this when installing on ubuntu 16.04.

If the specific download error is that java download link is 404, than mostly this solution will work.

Please remember to update the versions accordingly.

mdeora
  • 4,152
  • 2
  • 19
  • 29
0

This worked for me:

  • First, go to below path:

    cd /var/lib/dpkg/info

Run all 4 sed commands:

sudo sed -i 's|JAVA_VERSION=8u161|JAVA_VERSION=8u172|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u161-b12/2f38c3b165be4555a1fa6e98c45e0808/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="6dbc56a0e3310b69e91bb64db63a485bd7b6a8083f08e48047276380a0e2021e"|SHA256SUM_TGZ="28a00b9400b6913563553e09e8024c286b506d8523334c93ddec6c9ec7e9d346"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_161|J_DIR=jdk1.8.0_172|' oracle-java8-installer.*
  • Second:

    sudo apt-get install oracle-java8-installer

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
0

If OpenJDK also OK for you, try to use sdkman for installing all java staff) It's a very cool tool.

shoom
  • 11
  • 3