Ubuntu – Failing to install oracle-java7-installer,displaying ‘E: Sub-process /usr/bin/dpkg returned an error code (1)’

dependenciesdpkgjavajdksoftware installation

I was setting up up android-studio referring to this website. While installing oracle-java7-installer, this error is displayed:

sudo apt-get install oracle-java7-installer
[sudo] password for cyan: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
oracle-java7-installer is already the newest version (7u80+7u60arm-0~webupd8~1).
The following package was automatically installed and is no longer required:
  snap-confine
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up oracle-java7-installer (7u80+7u60arm-0~webupd8~1) ...
Downloading Oracle Java 7...
--2017-11-27 08:40:47--  http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
Resolving download.oracle.com (download.oracle.com)... 223.223.158.138, 223.223.158.136
Connecting to download.oracle.com (download.oracle.com)|223.223.158.138|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz [following]
--2017-11-27 08:40:47--  https://edelivery.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.58.58.93, 2600:140f:7:18e::2d3e, 2600:140f:7:18d::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.58.58.93|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1511752368_824528560c20825821ecbcac8f4e9be9 [following]
--2017-11-27 08:40:48--  http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1511752368_824528560c20825821ecbcac8f4e9be9
Connecting to download.oracle.com (download.oracle.com)|223.223.158.138|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-11-27 08:40:50 ERROR 404: Not Found.

download failed
Oracle JDK 7 is NOT installed.
dpkg: error processing package oracle-java7-installer (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 oracle-java7-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

How do I fix this error? I did a fresh installation of Ubuntu 16.04.

Best Answer

Oracle's Java 7 reached End of Life in 2015 and is no longer available. Java 8 is the best-supported version, though Java 9 is stable now as well (though things like IntelliJ IDEA don't yet support Java 9).