I have installed latest Sun JDk. But when I do:

java -version

I still got OpenJDK version. So I completely removed OpenJDK. But now when I do:

java -version

I get even older GNU java 1.5 something libgcj. So I completely removed that too but it was asking to remove bunch of dependent apps like OpenOffice.org Writer etc. Even though I need the writer, I let it go because I do not want ever to see the face of any GNU java on my linux. So everything related to GNU java is removed. Luckily I am able to start Eclipse and it works fine and start normally (apparently using the installed Sun JDK which is what I want). But now when I run

java -version

I get bash: /usr/bin/java: No such file or directory

Now what I need to do so that when I open any terminal window and enter java -version I should get Sun JDK version? Sun JDK is installed in /usr/java/jdk1.6.021. I also have symlinks: /usr/java/latest and /usr/java/defaults pointing to sun jdk.

As suggested in the answer, I tried the alternatives command but it did nothing. I type the --display, nothing is shown, and --config does nothing.

migrated from serverfault.com Mar 20 '11 at 10:17

This question came from our site for system and network administrators.

  • Why are you trying to get rid of GNU Java? – Sophie Alpert Mar 20 '11 at 18:14
  • @Ben: I'm trying to do the same thing. Primarily cause PhpStorm claims to be having issues with it. I don't care whether it does or not, at this point -- what's the deal with having to rip out half the system to get rid of it? What is this, Windows? – cHao Apr 16 '12 at 17:41

on Debian 5.0.8 (lenny), i just used:

sudo update-java-alternatives -s java-6-sun

You dont have to remove anything. On most Linux distros you can switch the java runtime environment. On fedora it is with alternatives.

To show which one is used:

alternatives --display java

To configure which one is used:

alternatives --config java

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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