Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.
 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

3 Answers 3

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? –  user142712 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 oracle.com/technetwork/java/javase/compatibility-417013.html and upstream-tracker.org/java/versions/jdk.html. 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

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? –  user142712 Mar 26 '13 at 5:44
There's Info here: linux.die.net/man/8/update-alternatives 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. " –  Mark Dec 17 '13 at 19:12

the GUI way

$ sudo apt-get install galternatives

$ sudo galternatives

more here: http://askubuntu.com/a/159594/216936

share|improve this answer

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.