Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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
 four@twenty:~$ file /etc/alternatives/java /etc/alternatives/javac
 /etc/alternatives/java:symbolic link to `/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java'
 /etc/alternatives/javac:symbolic link to `/usr/lib/jvm/java-6-openjdk-amd64/bin/javac'

Forgive my noobishness but Im interpreting that as the runtime environment using Java 7 but the compiler using 6?

Is this right and if so how can I set it to use 7?

Thanks :)

share|improve this question

Switching between installed Java versions can be accomplished using the update alternatives command.

  • To get a list of your installed Java platforms, run the following command from the terminal:

    sudo update-alternatives --config java

    This will give you a list output similar to this:

    There are 2 choices for the alternative java (providing /usr/bin/java).
       Selection    Path                                           Priority   Status
      0            /usr/lib/jvm/java-6-oracle/jre/bin/java         1070      auto mode
      1            /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java   1051      manual mode
    * 2            /usr/lib/jvm/java-6-openjdk-i386/jre/bin/java   1069      manual mode
    Press enter to keep the current choice[*], or type selection number: 

In this case, the Open JDK 6 version is running. To switch to the Open JDK version 7, you would select option 1 at the prompt and press the Enter key.

You will now be running the OpenJDK 7 version. No other changes will be needed to switch your Java versions.

share|improve this answer
Okay thanks. Would I gain anything from uninstalling jkd6? – Wingsuit Mar 26 '13 at 5:40
@user142712 No problem. I believe that an uninstall would also remove the older browser plugin, which is beneficial security-wise. – Kevin Bowen Mar 26 '13 at 5:52
I wouldn't go for the "No problem" answer so fast. Check and There is no 100% compatibility between those two major versions and it might happen so (unlikely but still...) that you have an application X that cannot run properly with the seventh version. Until you make sure there will be no issues I strongly advice to keep both just in case you need the previous version. – rbaleksandar Jul 3 '14 at 15:02
Just to be clear. The "no problem" comment was another way of me saying you are welcome, I never claimed that there would be no problems with your Java installation. – Kevin Bowen Apr 30 '15 at 0:55
you need to do this for javac as well in case you wanna change the compiler as well. – KillBill Feb 23 at 5:01

You can run sudo update-alternatives --config java, and select JDK 7, if it's installed.

share|improve this answer
Okay cheers, It says I have two of JKD7 installed one listing status as auto the other manual. Is there any difference? – Wingsuit Mar 26 '13 at 5:44
There's Info here: but i'd select auto. – Frederik Spang Mar 26 '13 at 7:45
"Each link group is, at any given time, in one of two modes: automatic or manual. When a group is in automatic mode, the alternatives system will automatically decide, as packages are installed and removed, whether and how to update the links. In manual mode, the alternatives system will not change the links; it will leave all the decisions to the system administrator. " – mpen Dec 17 '13 at 19:12

the GUI way

$ sudo apt-get install galternatives

$ sudo galternatives

more here:

share|improve this answer
You say that this is the GUI way; but, immediately, you resort to cli commands as resolution. Can you explain why this is a solution? – Kevin Bowen Feb 11 at 12:06
@KevinBowen This installs a GUI application. – WouterH Mar 23 at 14:46
WouterH is right.… thx wouterH – Alexander Sidikov Mar 23 at 14:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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