Ubuntu – dpkg broken by oracle-java8-installer

aptdpkgjavaoracle

I want to remove the oracle-java8-installer but it gives the below errors. Perhaps good to mention that I messed a bit with apt, e.g. at some point I manually removed the apt cache (but the java problem existed already and I do not think it has gotten worse).

~$ sudo apt-get remove --purge oracle-java8-installer
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED
  oracle-java8-installer*
0 to upgrade, 0 to newly install, 1 to remove and 25 not to upgrade.
1 not fully installed or removed.
After this operation, 129 kB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 693990 files and directories currently installed.)
Removing oracle-java8-installer (8u45+8u33arm-1~webupd8~1) ...
update-alternatives: warning: alternative /usr/lib/jvm/java-7-oracle/bin/javafxpackager (part of link group javafxpackager) doesn't exist; removing from list of alternatives
update-alternatives: error: unable to read link `/etc/alternatives/javafxpackager': Invalid argument
dpkg: error processing package oracle-java8-installer (--purge):
 subprocess installed pre-removal script returned error exit status 2
Installing from local file /var/cache/oracle-jdk8-installer/jdk-8u45-linux-x64.tar.gz
Removing outdated cached downloads...
mv: cannot move ‘jdk1.8.0_45’ to ‘java-8-oracle/jdk1.8.0_45’: Directory not empty
dpkg: error while cleaning up:
 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)

Here are the last lines of my dpkg log:

2015-07-28 22:14:14 startup packages purge
2015-07-28 22:14:14 status half-configured oracle-java8-installer:all 8u45+8u33arm-1~webupd8~1
2015-07-28 22:14:15 remove oracle-java8-installer:all 8u45+8u33arm-1~webupd8~1 <none>
2015-07-28 22:14:15 status half-configured oracle-java8-installer:all 8u45+8u33arm-1~webupd8~1

How can I get Java working again?

Best Answer

Simply remove the folder

sudo rm -r /usr/lib/jvm/java-8-oracle/jdk1.8.0_45

Still more you can not break. ;)

Now purge it again

sudo apt-get purge java-oracle8-installer

After that, install it again via the outdated PPA or the script in @Pilot6 answer.

Related Question