Programming‎ > ‎


Installing Java on Ubuntu

This documentation is targeted at Ubuntu 12.04 LTS. Some parts of it may not apply to other versions.

If you need to install Java on Ubuntu systems, there are two main choices, OpenJDK and Oracle Java/JDK. We recommend that you use OpenJDK, unless you have an application that requires Oracle Java.

Installation options:

Having multiple Java versions on a host

It is possible to have multiple Java packages installed on a single Ubuntu machine. Ubuntu uses the "alternatives" system to select a default between multiple packages that provide the same function. Typically, the alternatives system automatically selects the appropriate package. The current setting for a given alternative (java, in this example) can been seen with the following command:

update-alternatives --display java
The currently selected alternative can be set with this command:
update-alternatives --config java

Installing OpenJDK

OpenJDK is a free and open source implementation of the Java programming language. It has support from the Oracle Corporation and serves as the reference implementation of Java SE (Standard Edition). It is the basis for the Oracle Java products. Some additional information about OpenJDK is at:

OpenJDK can be installed via Ubuntu's package system by running this command:

sudo apt-get install openjdk-7-jdk icedtea-7-plugin

This will install the development environment ("javac" comes from the JDK), and runtime environment ("java" comes from the JRE), and the browser plugin. Firefox will automatically be configured to use the java plugin (though, Firefox may need to be restarted for this to take effect). This package will be updated automatically as new releases become available.

Installing Oracle JDK/Java

Oracle JDK/Java is a proprietary implementation of the Java programming language from the Oracle Corporation. It is based on the OpenJDK with the addition of some closed-source components. Canonical no longer packages Oracle Java for Ubuntu due to licensing restrictions, but some older packages may require that the Oracle JDK be installed.

The Ubuntu community provides instructions for several different methods of installing Oracle Java. Note: These suggestions are not endorsed by SCS Facilities or by MES, as they range from manually unpacking tarballs directly into your filesystem to allowing untrusted third parties to provide arbitrary software packages to your system. Additionally, none of the community-suggested methods are guaranteed to be automatically kept up-to-date with patches. You are responsible for making sure that your Java installation is kept current with security updates and other patches. It is important that you do so, since critical security vulnerabilities are frequently found in Java.

Additional resources
Ubuntu community documentation that covers the steps required to install Java and has pointers to further choices.

Following link could be useful for more on it