I deleted /etc/alternatives/java
Solution 1
On Ubuntu (and other Debian based distributions) /usr/bin/java
is just a symlink to /etc/alternatives/java
, which is itself a symlink to /usr/lib/jvm/$SOMEVERSION/bin/java
.
This way you can choose your preferred java version just by changing this one link.
As you removed /etc/alternatives/java
you can just create a new link using:
ln -s /usr/lib/jvm/jdk1.7.0_45/jre/bin/java /etc/alternatives/java
Alternatively you should be able to use the alternatives-system:
update-alternatives --set java /usr/lib/jvm/jdk1.7.0_45/jre/bin/java
Solution 2
See man update-alternatives
. This is slightly different on fedora than debian/ubuntu but seems to amount to the same thing; it's used by the package manager to maintain the symlinks in /etc/alternatives
, but it can be used manually.
--all
Call --config on all alternatives. It can be usefully combined with --skip-auto to review and configure all alternatives which are not configured in automatic mode. Broken alternatives are also displayed. Thus a simple way to fix all broken alternatives is to callyes '' | update-alternatives --force --all
.
So I would try that first, presuming the java you are talking about is a distro package java.
![Binary Code](https://i.stack.imgur.com/GF0Xn.png?s=256&g=1)
Binary Code
I'm a student in computer science in the engineering school ENSEIRB-Matmeca.
Updated on September 18, 2022Comments
-
Binary Code almost 2 years
I'm on Ubuntu 12.04 on a 32-bits Dell machine.
I was trying to install java JDK for 32-bits linux platform and I accidentally deleted the file /etc/alternatives/java.
I would love to recreate my old good file in order to build the link with /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java OR with /usr/lib/jvm/jdk1.7.0_45/jre/bin/java I don't really which one I have to build, but to try I need my alternative executable.
-
user over 10 yearsI don't think this can be answered as it stands. At a minimum, you need to specify which OS, distribution and version you're on. (An answer that works for Debian Wheezy likely won't be much help if you're running FreeBSD, or Mac OS X, for example.) Also, are we to assume that you don't have any suitable backup? If you're on Linux, consider checking your distribution's repository to find out which package provides the needed files and simply reinstall that package through the package manager.
-
-
Binary Code over 10 yearsThank you very much ! You saved my day :D ! And you just enligthened me on this alternatives repository.
-
michas over 10 yearsNo need to thank. Just accept the answer by clicking on the check mark next to the answer.
-
Tagar about 9 years+1 although seems not working on RHEL