0

I completely uninstalled Java following this post. Unfortunately, I am no longer able to reinstall Java.

To reinstall Java, I ran the following command:

$ sudo apt install default-jre

When I now try to check the version of Java with the command

$ java -version

I get the following output:

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

However, when (re)running sudo apt install default-jre, I get:

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 3 not upgraded.

Any help on how to reinstall Java after completely uninstalling via this post? I already read many articles on the internet but I am not able to resolve this issue.

The output of the command

$ apt list --installed | egrep 'jdk|jre'

results in:

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

default-jdk/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed]
default-jdk-headless/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed,automatic]
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,automatic]
openjdk-11-jdk/bionic-updates,bionic-security,now 11.0.4+11-1ubuntu2~18.04.3 amd64 [installed]
openjdk-11-jdk-headless/bionic-updates,bionic-security,now 11.0.4+11-1ubuntu2~18.04.3 amd64 [installed,automatic]
openjdk-11-jre/bionic-updates,bionic-security,now 11.0.4+11-1ubuntu2~18.04.3 amd64 [installed,automatic]
openjdk-11-jre-headless/bionic-updates,bionic-security,now 11.0.4+11-1ubuntu2~18.04.3 amd64 [installed]
openjdk-8-jdk/bionic-updates,bionic-security,now 8u222-b10-1ubuntu1~18.04.1 amd64 [installed]
openjdk-8-jdk-headless/bionic-updates,bionic-security,now 8u222-b10-1ubuntu1~18.04.1 amd64 [installed]
openjdk-8-jre/bionic-updates,bionic-security,now 8u222-b10-1ubuntu1~18.04.1 amd64 [installed,automatic]
openjdk-8-jre-headless/bionic-updates,bionic-security,now 8u222-b10-1ubuntu1~18.04.1 amd64 [installed]
0

1 Answer 1

2

It seems that following that answer you deleted all the Java related binaries but didn't actually removed OpenJDK packages. You can reinstall them by running

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .