1

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.

0

Have you tried just doing it through the Ubuntu Software center? If that didn't work you should be able to run

sudo apt-get update
sudo apt-get install default-jdk
  • I forgot to add. Yes, I have already tried this too. No change. – Ethan Z Apr 30 '16 at 22:06
  • @EthanZ Can you paste the terminal output after running sudo apt-get install default-jdk – kalenpw Apr 30 '16 at 22:09
  • I'm not in front of my laptop ATM, but it installed normally and reported that 0 files were downloaded, 0 were updated, and a whole lot were unchanged. – Ethan Z Apr 30 '16 at 22:10
  • @EthanZ Hmm might already have java installed and it's an issue with java. When possible can you try "java -version" see if has anything if so you can try "sudo apt-get remove default-jdk" and then try reinstalling – kalenpw Apr 30 '16 at 22:12
  • What has me dumbfounded is that IntelliJ IDEA sees java and is perfectly happy with it. Java -version returns the same "java was found in the following packages" message. I'll try removing the jdk but I'm concerned of whether or not it will even see it considering it suggests reinstalling packages I already have. – Ethan Z Apr 30 '16 at 22:15
0

You could also try using the Oracle JDK instead of OpenJDK. These instructions are great: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04

Personally I would go with the Oracle version.

I have messed up java installs myself and it's no fun to sort out :(

  • I attempted this over a half a year ago when this question was asked. Made no difference. Only fix was a clean install. – Ethan Z Dec 22 '16 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.