

sudo apt-get install oracle-java7-installer sudo apt-get install oracle-java6-installer Then, depending on the version you want to install, execute one of the following commands: Oracle JDK 6 Sudo add-apt-repository ppa:webupd8team/java

To install any version, first execute the following commands: sudo apt-get install python-software-properties The Oracle JDK is the official JDK however, it is no longer provided by Oracle as a default installation for Ubuntu. If you instead need the Java Development Kit (JDK), execute the following command: sudo apt-get install openjdk-7-jdk This will install the Java Runtime Environment (JRE). To install OpenJDK 7, execute the following command: sudo apt-get install openjdk-7-jre Since the JDK contains the JRE, there are no disadvantages if you install the JDK instead of the JRE, except for the larger file size.Īll other steps are optional and must only be executed when needed. The JDK is usually only necessary if you are going to compile Java programs or if your software specifically requires it in addition to Java. If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command: sudo apt-get install default-jdk

If it returns “The program java can be found in the following packages”, Java hasn’t been installed yet, so execute the following command: sudo apt-get install default-jre Then, check if Java is not already installed: java -version First, update the package index: sudo apt-get update This will install OpenJDK 6 on Ubuntu 12.04 and earlier and on 12.10+ it will install OpenJDK 7. This is the recommended and easiest option. This tutorial will guide you through the process of installing and managing different versions of Java on Ubuntu 12.04. Having Java installed is a prerequisite for many articles and programs. We strongly recommend using the following guide for working with Java on Ubuntu: How To Install Java with Apt-Get on Ubuntu 16.04. This guide might still be useful as a reference, but may not work on other Ubuntu releases. Reason: Ubuntu 12.04 reached end of life (EOL) on Apand no longer receives security patches or updates. Migrate the server data to a supported version.Upgrade from Ubuntu 14.04 to Ubuntu 16.04.

If you are currently operating a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu: This article covers a version of Ubuntu that is no longer supported.
