0

I have follow all the post but unable to solve this problem:

By mistake I deleted the /usr/bin/java. After installing many time m still getting this error.

After running update-alternatives --display java I'm getting:

update-alternatives: error: no alternatives for java
David Foerster
  • 35,754
  • 55
  • 92
  • 145
Gaurav Singh
  • 131
  • 2
  • 9

1 Answers1

1

In a terminal, run the following:

update-java-alternatives -l | awk '{ print $1; }'

Pick one of the listed options, and run:

sudo update-java-alternatives -s the-option-you-chose
Chai T. Rex
  • 5,126
  • 1
  • 24
  • 48
  • after running update-java-alternatives -l | awk '{ print $1; }' output what i get is java-1.7.0-openjdk-amd64 and then i run sudo update-java-alternatives -s java-1.7.0-openjdk-amd64 i get update-java-alternatives: directory does not exist: /usr/lib/jvm/java-1.7.0-openjdk-amd64 – Gaurav Singh Jun 04 '17 at 05:12
  • 1
    In that case, it's likely that OpenJDK itself was removed. To reinstall, assuming you're using Ubuntu 14.04, use either `sudo apt-get install --reinstall openjdk-7-jre` or `sudo apt-get install --reinstall openjdk-7-jdk`. – Chai T. Rex Jun 05 '17 at 02:18