2

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.

closed as unclear what you're asking by a CVn, Anthon, Renan, slm, jasonwryan Nov 11 '13 at 16:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I 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. – a CVn Nov 11 '13 at 10:34
3

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
  • Thank you very much ! You saved my day :D ! And you just enligthened me on this alternatives repository. – Hugo Nov 11 '13 at 14:58
  • No need to thank. Just accept the answer by clicking on the check mark next to the answer. – michas Nov 11 '13 at 16:02
1

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 call yes '' | update-alternatives --force --all.

So I would try that first, presuming the java you are talking about is a distro package java.

  • +1 although seems not working on RHEL – Tagar May 31 '15 at 19:50

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