There is an error during install jre1.8.0.72. How should I remove it? I get an error during purge:

sudo apt-get purge jre1.8.0-72

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
0 to upgrade, 0 to newly install, 1 to remove and 26 not to upgrade.
1 not fully installed or removed.
After this operation, 126 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 454719 files and directories currently installed.)
Removing jre1.8.0-72 ...
/var/lib/dpkg/info/jre1.8.0-72.postrm: line 586: /usr/sbin/alternatives: No such file or directory
dpkg: error processing jre1.8.0-72 (--remove):
 subprocess installed post-removal script returned error exit status 127
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • Do you remember how you installed Java in the first place? – Raphael Jan 30 '16 at 13:43
  • I just use the sudo dpkg -i jre1.8.0-72.deb to install. – Bangyou Jan 30 '16 at 13:47
  • Where did you download it from? – Raphael Jan 30 '16 at 13:51
  • download from here:oracle.com/technetwork/java/javase/downloads/… – Bangyou Jan 30 '16 at 13:58
  • Its good that you solved your issue, but there aren't any *.deb files in the link you redirected to. Are you sure you installed it in that way? – Raphael Jan 30 '16 at 14:01

If you installed Java using Webupd8 script, then to uninstall Java do the following:

sudo apt-get remove --purge oracle-java8-installer

If you installed Java from Ubuntu repositories, then you can remove it by typing:

sudo apt-get remove --purge openjdk-*
| improve this answer | |
  • Thanks for your help. I think I solved my problem through create a empty file "/usr/sbin/alternatives" – Bangyou Jan 30 '16 at 13:58
  • Nice! that you solved your own question. Post your answer and accept it. – Raphael Jan 30 '16 at 14:00
  • Will post it tomorrow morning (very late now) – Bangyou Jan 30 '16 at 14:10

To uninstall the existing Java , you can execute the following command:

sudo apt-get remove openjdk-8-jre
sudo apt-get remove openjdk-8-jre-lib

To install the Java V8 again,

sudo apt-get install openjdk-8-jdk
| improve this answer | |

This error /usr/sbin/alternatives: No such file or directory can be solved to create a empty file.

| improve this answer | |
  • I recommend editing this answer to expand it with specific details about how to do this. (See also How do I write a good answer? for general advice about what sorts of answers are considered most valuable on Ask Ubuntu.) – David Foerster Mar 23 '16 at 23:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.