Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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.

share|improve this question

migrated from 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? – Ben 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
share|improve this answer

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
share|improve this answer

You must log in to answer this question.