By default, Ubuntu 12.04 comes with OpenJDK 6, which is by now quite old and some applications require at least Java 7. How can I update an Ubuntu 12.04 installation to Java 7?


The Ubuntu 12.04 repositories contain both version 6 and 7 of the JDK, but by default only version 6 is installed.

To update, it is best to use the Synaptic package manager – if you don’t have it, install it with sudo apt-get install synaptic.

  • Note: Ensure that Java 7 packages are selected before deselecting any Java 6 packages – else Synaptic will deselect anything that depends on Java (including any Java applications)!
  • Search for icedtea and select icedtea-7-plugin for installation. This may select some Java 7 dependencies.
  • Now search for openjdk and deselect openjdk-6 as well as openjdk-6-jre. This may deselect some further packages.
  • If you had openjdk-6-jdk installed, make sure it is now selected for removal and openjdk-7-jdk is selected for installation. (You can skip this step if openjdk-6-jdk is not selected, meaning it was never installed.)
  • Click Apply and review your package selections:

    • default-jre packages are metapackages which are safe to remove in this process.
    • icedtea-7-jre-cacao is a dummy package, therefore it it OK to remove icaedtea-6-cacao without installing a replacement.
    • For any other Java/IcedTea 6 package that is removed, you should be installing the Java 7 equivalent.
    • Packets to be selected for removal should include the following:
      • default-jre
      • default-jre-headless
      • icedtea-6-jre-cacao
      • icedtea-6-jre-jamvm
      • openjdk-6-jre
      • openjdk-6-jre-headless
      • openjdk-6-jre-lib
    • Instead, the following should be installed:
      • icedtea-7-jre-jamvm
      • icedtea-7-plugin
      • openjdk-7-jre
      • openjdk-7-headless
      • openjdk-7-lib
  • If any packages are missing, go back and select them manually. When everything is OK, install.

From a console, run java -version. If you have JDK installed, also run javac -version. Both should now report version 1.7.0.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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