linux | Linux‎ > ‎

linux | Install JAVA in linux


Written by  | Date: Wednesday, September 05, 2012 

Update: Oracle Java 8 is now stable. Below you'll find instructions on how to install it in Ubuntu / Linux Mint via a PPA repositoryThe PPA supports JDK8 for both 32bit and 64bit as well as ARM (ARM v6/v7 Hard Float ABI - there's no JDK 8 ARM Soft Float ABI archive available for download on Oracle's website).

As a reminder, the WebUpd8 Oracle Java PPA doesn't include any Java binaries, just a script that automatically downloads and install Oracle Java 8. Everything is done automatically so you'll get updates through the update manager for JDK8 which includes JRE8 and the Java browser plugin.

It's also important to note that the Oracle Java 8 installer is considered in alpha and is offered without any guarantees! Use it at your own risk. If you ISP or router blocks the ports used by the Oracle Java 8 download servers, the installation may fail.

Another important note: Ubuntu 13.04 is no longer supported by Canonical: there will be no security updates and they don't allow uploading new packages to Launchpad PPAs so the JDK8 version in the PPA for Ubuntu 13.04 is old and unsupported!

If you want to install Oracle Java 7 instead, see THIS post (PPA for Ubuntu 14.04, 13.10, 12.10, 12.04 and 10.04).

Debian users will find installation instructions in the following article: How To Install Oracle Java 8 In Debian Via Repository [JDK8]

Install Oracle Java 8 (JDK8 and JRE8) in Ubuntu / Linux Mint

Oracle JDK8 installer

Oracle JDK8 installer

The installer provides Oracle Java 8 (which includes Java JDK, JRE and the Java browser plugin). However, you can't only install Oracle JRE - the PPA only provides the full Oracle JDK8 package. 

Our PPA supports Ubuntu 14.04, 13.10, 12.10, 12.04 and 10.04 as well as the corresponding Linux Mint versions. Add the PPA and install Oracle Java 8 (the package provides both JDK8 and JRE8) using the following commands:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

Once installed, running "java -version" in a terminal should output something like this:
andrei@andrei-desktop:~$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
Or, "javac -version":
andrei@andrei-desktop:~$ javac -version
javac 1.8.0
And so on.

Automated installation (auto accept license)

The installer requires you to accept the Oracle license before the installation begins. This is only required once. If for some reason you need the installation to be automated, you can run the following command to automatically accept the Oracle license:
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

Switching between Oracle Java 8 and Java 7

Later on, if you want to switch Oracle Java 7, use the following command (make sure "oracle-java7-installer" package is installed):
sudo update-java-alternatives -s java-7-oracle

And, switch back to Oracle Java 8 using:
sudo update-java-alternatives -s java-8-oracle
If you get some warnings when running these two commands, ignore them.

Setting Java environment variables

To automatically set up the Java 8 environment variables, you can install the following package:
sudo apt-get install oracle-java8-set-default

If you've already installed oracle-java6-set-default or oracle-java7-set-default, they will be automatically removed when installing oracle-java8-set-default (and the environment variables will be set for Oracle Java 8 instead).