Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have both java-6-openjdk and java-7-openjdk installed on my machine. When I check the version, I get java version "1.6.0_27". I want to run java 7 but don't really know what all I have to change to accomplish the change.

Is it as simple as changing the link from /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java /etc/alternatives/java -> /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java?

share|improve this question

2 Answers 2

You can use sudo update-alternatives --config java to change the version of Java that is used. Don't manually change the linking of anything in /etc/alternatives/java. This is described well in Changing JVM in Java.

Alternatively, if you don't plan on using Java 6 in the future, you can remove Java 6 in its entirety. Running sudo apt-get purge openjdk-6-jre openjdk-6-jre-headless should work. If you also installed the JDK, the package name of that is openjdk-6-jdk.

share|improve this answer

@saiarcot895's answer works, but to automate the process (avoiding the prompting) I used:

update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin/java" 1
udpate-alternatives --set java /usr/lib/jvm/java-1.7.0-openjdk-i386/jre/bin/java

Just remember to adjust the paths and vendors according to your case.

And make sure to check out the manual: man update-alternatives

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.