1

I wanted to reinstall java which was accidently deleted, using this post.

As mentioned in the above post on runningsudo apt install default-jre, I got this error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jre is already the newest version (2:1.11-68ubuntu1~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 149 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 install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 3: /etc/environment: JAVA_HOME: not found
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

The result of java --version is:

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless 

The result of apt list --installed | egrep 'jdk|jre' is:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

default-jre/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed]
default-jre-headless/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed]
openjdk-11-jre/bionic-updates,bionic-security,now 11.0.7+10-2ubuntu2~18.04 amd64 [installed]
openjdk-11-jre-headless/bionic-updates,bionic-security,now 11.0.7+10-2ubuntu2~18.04 amd64 [installed]
openjdk-8-jdk/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jdk-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jre/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jre-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]

As mentioned in the post tried this to fix the error:

sudo apt install --reinstall default-jre default-jdk default-jre-headless default-jdk-headless openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless

But, it gave the same error.

The result of echo $JAVA_HOME is: /usr/lib/jvm/java-11-openjdk-amd64/bin

The result of echo $PATH is:

/home/.local/bin:/home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bin:/usr/lib/jvm/jdk1.7.0/bin:/home/bin:/usr/lib/jvm/jdk1.7.0/bin:/usr/lib/jvm/java-11-openjdk-amd64/bin

I found that these links are broken,

usr/share/man/man1/jar.1.gz

usr/share/man/man1/jarsigner.1.gz

usr/share/man/man1/java.1.gz

usr/share/man/man1/javac.1.gz

usr/share/man/man1/javadoc.1.gz

usr/share/man/man1/javah.1.gz

usr/share/man/man1/javap.1.gz

When tried to open these file from the interface, got a warning message that these links cannot be used as it's alternatives does not exists in "/etc/alternatives/ "

The result of /usr/share/man/man1# update-alternatives --config java as a root user is:

update-alternatives: warning: alternative /usr/lib/jvm/java-11-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/java is dangling; it will be updated with best choice
There is no program which provides java.
Nothing to configure.

Looking at the inconvenience in reinstalling java as it seems it's not fully installed or removed, tried to completely uninstall java using this post.

As mentioned in this post, ran the following command:

dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove

But even this didn't worked giving out the same error while processing.

The result of apt update && apt dist-upgrade is:

Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [306 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [279 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,972 B]
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [43.8 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [49.2 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 943 kB in 4s (267 kB/s)                                        
Reading package lists... Done
Building dependency tree       
Reading state information... Done
148 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  libnetplan0 linux-headers-5.3.0-59 linux-headers-5.3.0-59-generic
  linux-image-5.3.0-59-generic linux-modules-5.3.0-59-generic
  linux-modules-extra-5.3.0-59-generic
The following packages will be upgraded:
  apport apport-gtk apt apt-utils aptdaemon aptdaemon-data bind9-host
  ca-certificates clamav clamav-base clamav-freshclam cups cups-bsd
  cups-client cups-common cups-core-drivers cups-daemon cups-ipp-utils
  cups-ppdc cups-server-common debootstrap distro-info-data dmeventd dmsetup
  dnsutils exim4 exim4-base exim4-config exim4-daemon-light file firefox
  firefox-locale-en gir1.2-javascriptcoregtk-4.0 gir1.2-snapd-1
  gir1.2-webkit2-4.0 intel-microcode iproute2 kmod libapt-inst2.0
  libapt-pkg5.0 libbind9-160 libclamav9 libcups2 libcupscgi1 libcupsimage2
  libcupsmime1 libcupsppdc1 libdevmapper-event1.02.1 libdevmapper1.02.1
  libdns-export1100 libdns1100 libexif12 libfreerdp-client2-2 libfreerdp2-2
  libirs160 libisc-export169 libisc169 libisccc160 libisccfg160
  libjavascriptcoregtk-4.0-18 libjpeg-turbo8 libjpeg-turbo8-dev libjson-c3
  libkmod2 libldap-2.4-2 libldap-common liblvm2app2.2 liblvm2cmd2.02
  liblwres160 libmagic-mgc libmagic1 libmysqlclient-dev libmysqlclient20
  libnss-myhostname libnss-systemd libopenexr22 libpam-systemd
  libpulse-mainloop-glib0 libpulse0 libpulsedsp libsmbclient libsnapd-glib1
  libsqlite3-0 libssl-dev libssl1.1 libsystemd0 libudev1 libvirt-bin
  libvirt-clients libvirt-daemon libvirt-daemon-driver-storage-rbd
  libvirt-daemon-system libvirt0 libwbclient0 libwebkit2gtk-4.0-37 libwinpr2-2
  linux-firmware linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04
  linux-image-generic-hwe-18.04 linux-libc-dev lvm2 mysql-client-5.7
  mysql-client-core-5.7 mysql-server mysql-server-5.7 mysql-server-core-5.7
  netplan.io nplan openssl pulseaudio pulseaudio-module-bluetooth
  pulseaudio-utils python-apt-common python-flask python3-apport python3-apt
  python3-aptdaemon python3-aptdaemon.gtk3widgets python3-problem-report
  python3-software-properties python3-update-manager qemu-block-extra qemu-kvm
  qemu-system-common qemu-system-x86 qemu-utils remmina remmina-common
  remmina-plugin-rdp remmina-plugin-secret remmina-plugin-vnc samba-libs
  shotwell shotwell-common software-properties-common software-properties-gtk
  sqlite3 systemd systemd-sysv thunderbird thunderbird-gnome-support
  thunderbird-locale-en thunderbird-locale-en-us tzdata udev update-manager
  update-manager-core
148 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 3,777 kB/333 MB of archives.
After this operation, 349 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 sqlite3 amd64 3.22.0-1ubuntu0.4 [752 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsqlite3-0 amd64 3.22.0-1ubuntu0.4 [499 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 intel-microcode amd64 3.20200609.0ubuntu0.18.04.1 [2,526 kB]
Fetched 3,777 kB in 11s (353 kB/s)                                             
Extracting templates from packages: 100%
Preconfiguring packages ...
Setting up install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 3: /etc/environment: JAVA_HOME: not found
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

Please provide suggestions to fix this error which restricts installation or removal of any package.

  • remove all the unnecessary sources from sources.list , you can find them here `/etc/apt/sources.list.d/`. Then run **apt update && apt dist-upgrade**, then run `apt --fix-broken install`. After these try again apt cmd for java – Silverfang Jun 15 '20 at 09:16
  • Even after removing all the unnecessary sources from sources.list, on running ```apt update && apt dist-upgrade``` got the same error. – Divya Juhi Singh Jun 15 '20 at 11:17
  • what kind of error ? – Silverfang Jun 15 '20 at 11:19
  • I have edited my answer and mentioned the error in detail. Please check in. – Divya Juhi Singh Jun 15 '20 at 11:28
  • now try this `apt --fix-broken install` – Silverfang Jun 15 '20 at 11:34
  • Even tried that thereafter, but didn't worked. – Divya Juhi Singh Jun 15 '20 at 11:37
  • What is the environment setting for java in here `/etc/environment` – Silverfang Jun 15 '20 at 11:39
  • `apt list --installed | egrep 'jdk|jre'` Since this command is still giving you Your java version then that means that you have not uninstalled the java correctly. You have followed [this](https://askubuntu.com/questions/84483/how-to-completely-uninstall-java). Please run all the command mentioned there. As your uninstall is incomplete. – Silverfang Jun 15 '20 at 11:52
  • The environment setting of java in ```/etc/environment``` is ```PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"``` ```JAVA_HOME = ":usr/lib/jvm/java-11-openjdk-amd64/bin``` ```CLASSPATH = ":usr/lib/jvm/java-11-openjdk-amd64/bin:/home/divya/Destop" ``` – Divya Juhi Singh Jun 15 '20 at 14:00
  • Even after completely following [this](https://askubuntu.com/questions/84483/how-to-completely-uninstall-java), ```dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove``` and ```apt list --installed | egrep 'jdk|jre'``` gives out the same result as before. – Divya Juhi Singh Jun 15 '20 at 14:06
  • Kindly check this if you are using Ubuntu 20.04 https://stackoverflow.com/a/67190390/1718445 – Edwin M Nov 09 '22 at 07:58

0 Answers0