Possible Duplicate:
How do I make java default to a manually installed JRE/JDK?

I've got the following in /.bashrc

    export JAVA_HOME=/usr/bin/jdk1.7.0_03/ 
export PATH=$PATH:/usr/bin/jdk1.7.0_03/bin

This is fine, if I do $JAVA_HOME I get the directory above.

The problem is if I do java -version I get...

OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

How do I make the official jdk version the right one?


1 Answer 1


You'll need to get into the command line for this one (although I expect you're happy with that if you've installed the JDK!).

Open a terminal using Ctrl+Alt+t. Then type:

sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws

I see you're new to Ubuntu so I'll explain some of these commands. Sudo tells the computer to execute the following command with the super-user's privileges. You will therefore be asked for your password. Update-alternatives keeps track of what your preferred options are when you have several software packages providing similar functionality, such as different JDKs. The rest is just telling update-alternatives what you'd like to configure. Never enter commands in a terminal if you don't know roughly what they'll do. If in doubt, enter man <command name> in the terminal to read the command's manual.

Not the answer you're looking for? Browse other questions tagged .