I have been fighting with Java for nearly a week now. Please bear with me, I'm very new to linux and Ubuntu.
I first attempted to install the JDK as the following site had written, which did not work.http://openjdk.java.net/install/. Right after installing, I once again tried to use java from the command line and nothing happened. I was told that
java The program 'java' can be found in the following packages: * default-jre * gcj-4.9-jre-headless * gcj-5-jre-headless * openjdk-8-jre-headless * gcj-4.8-jre-headless * openjdk-9-jre-headless Try: sudo apt install
I went ahead and installed the open jdk java 8 runtime and set my path and java home environmental variables. I tried the java command again, and nothing. It acted as if java was not installed and I got the same exact printout as when i started.
After rummaging through tons of sites, I tried the javac command and noticed that despite not working, it did exist.
javac: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory
This lead me to finding that inside of the usr/bin/ directory, all of the java commands except java itself exist, and the others just don't work. In other words, I'm in shambles at this point.
I also tried installing the default jre using apt-get and that didn't work either.
Does anyone know why this is happening and what I can do to fix it? Thank you.
PS. If a clean wipe is what's necessary, I am open to that. I've barely had Ubuntu running for 2 weeks and it wouldn't be incredibly troublesome to do so.
EDIT: I eventually relented. I reinstalled Ubuntu from scratch and followed the procedure in the first answer. Everything works properly now.