Cannot remove JDK – /usr/sbin/alternatives: No such file or directory
9,412
Solution 1
Try creating a file in that folder and executing the uninstall command then:
sudo mkdir -p /usr/java
sudo touch /usr/java/aa
sudo touch /usr/sbin/alternatives
sudo apt-get remove jdk1.8.0-40
EDIT:
Try this: echo "" | sudo tee /var/lib/dpkg/info/jdk1.8.0-40.postrm
Solution 2
/usr/sbin/alternatives: No such file or directory
There is no
/usr/sbin/alternatives
in Debian, Ubuntu, etc. Debian clones. Instead there is/usr/bin/update-alternatives
.I suggest a temporary symbolic link to work around the badly converted RPM package:
mkdir -p /usr/sbin ln -sT -- /usr/bin/update-alternatives /usr/sbin/alternatives
(source)
Related videos on Youtube
Author by
Adrian Christensen
Updated on September 18, 2022Comments
-
Adrian Christensen over 1 year
When I try to remove Java with
sudo apt-get remove jdk1.8.0-40
I get this:Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: jdk1.8.0-40 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 245 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 231488 files and directories currently installed.) Removing jdk1.8.0-40 (1.8.040-1) ... find: `/usr/java/*': No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: No such file or directory dpkg: error processing package jdk1.8.0-40 (--remove): subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing: jdk1.8.0-40 E: Sub-process /usr/bin/dpkg returned an error code (1)
Output of
ls -1 /var/cache/apt/archives/*jdk*
:openjdk-7-jre_7u75-2.5.4-1~trusty1_amd64.deb openjdk-7-jre-headless_7u75-2.5.4-1~trusty1_amd64.deb
Output of
sudo dpkg --purge --force-all jdk1.8.0-40
:(Reading database ... 231488 files and directories currently installed.) removing jdk1.8.0-40 (1.8.040-1) ... /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: No such file or directory dpkg: error processing package jdk1.8.0-40 (--purge): subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing: jdk1.8.0-40
When trying the edit I get this:
(Reading database ... 231488 files and directories currently installed.) Removing jdk1.8.0-40 (1.8.040-1) ... /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: Permission denied /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: Permission denied dpkg: error processing package jdk1.8.0-40 (--remove): subprocess installed post-removal script returned error exit status 126 Errors were encountered while processing: jdk1.8.0-40 E: Sub-process /usr/bin/dpkg returned an error code (1)
-
sugab about 9 yearstry this first, and then try to remove again,
sudo dpkg-reconfigure jdk1.8.0-40
-
-
Adrian Christensen about 9 yearsNow i get this: Removing jdk1.8.0-40 (1.8.040-1) ... /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-40.postrm: line 598: /usr/sbin/alternatives: No such file or directory dpkg: error processing package jdk1.8.0-40 (--remove): subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing: jdk1.8.0-40 E: Sub-process /usr/bin/dpkg returned an error code (1)
-
Adrian Christensen about 9 yearsWhen running sudo dpkg-reconfigure i get: /usr/sbin/dpkg-reconfigure: jdk1.8.0-40 is broken or not fully installed
-
0x2b3bfa0 about 9 yearsPlease update your post with the output of this command:
ls /var/cache/apt/archives/ | grep -i jdk
-
Adrian Christensen about 9 yearsNow i have updated the post.
-
0x2b3bfa0 about 9 yearsTry this:
sudo dpkg --purge --force-all jdk1.8.0-40
-
Adrian Christensen about 9 yearsDosent Work Output in main post.
-
0x2b3bfa0 about 9 yearsLet's try the edit to my answer
-
Adrian Christensen about 9 yearsThen i get permission denied error specific in main post.
-
0x2b3bfa0 about 9 yearsTry this:
echo "" | sudo tee /var/lib/dpkg/info/jdk1.8.0-40.postrm
and then uninstall.