Ubuntu 18.04 Java Command Not Found Despite Being Installed

tjsucksatcoding picture tjsucksatcoding · Feb 24, 2020 · Viewed 7.4k times · Source

I initially had default-jdk and default-jre installed on Ubuntu 18.04.

Attempted to host a Minecraft Server for a friend, but was given the error found here

I followed the commentor's advice to reinstall java version 8 rather than version 11 installed above, by following this advice here that being

sudo rm -r /usr/lib/jvm/java-11-oracle

but as a mistake I had removed all files in that folder, leaving just the two directories

  1. java-11-openjdk-amd64
  2. java-8-openjdk-amd64

since then I have attempted to reinstall java using sudo apt-get install default-jdk ; sudo apt-get install default-jre and they install just fine, but running java -version, either as root or as user, returns:

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

  1. sudo apt install default-jre
  2. sudo apt install openjdk-11-jre-headless
  3. sudo apt install openjdk-8-jre-headless

I have scoured askubuntu, digitalocean, and stackoverflow for some answers but I can't find anything that fixes this problem. I also asked my roommate, who is an experienced Computer Science major and who has used ubuntu extensively in the past, and he couldn't find a solution. Has anyone encountered this issue before?

I appreciate any and all responses 😊

Answer

tjsucksatcoding picture tjsucksatcoding · Feb 25, 2020

Solution has been found. Running:

sudo apt purge -y openjdk-11-jre-headless
sudo apt purge -y openjdk-8-jre-headless
sudo apt purge -y default-jdk

and reinstalling has resolved the issue