The Oracle Java 7 installer in this article will continue to work only if you manually download Oracle JDK 7 (version 7u80 for 32bit and 64bit or 7u60 for arm), place it in the /var/cache/oracle-jdk7-installer/ folder on your computer, then install "oracle-java7-installer" as explained below in this article.
---------------------------------------------------------------------------
We've previously written about installing Oracle JDK 7 in Ubuntu using a script with a GUI provided by Zenity. Some may find this method hard to use and also, it comes with GTK dependencies. So as an alternative that doesn't have any GTK dependencies and comes with automatic updates too, I've set up an Ubuntu PPA for the latest Oracle Java 7 (JDK). The PPA should work not only with Ubuntu but also Linux Mint and other Ubuntu-based Linux distributions.
If you really need to use Oracle (ex Sun) Java instead of OpenJDK in Ubuntu, here's an easy way to do it: a PPA repository to install and keep your computer up to date with the latest Oracle Java 7 (Java JDK which includes JRE).
Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads Oracle Java JDK 7 from its official website and installs it on your Ubuntu / Linux Mint computer, just like the flashplugin-installer package does.
Please note that this package is currently in alpha and is offered without any guarantees, so it may or may not work! Use it at your own risk! The package should support proxies just like the flashplugin-installer does, but it may fail if your ISP or router blocks some non-standard ports because Oracle uses quite a few redirects for the Java 7 binary download links. If the download fails because of blocked ports or because you're behind a firewall, use the manual Oracle Java 7 installation method (link in the beginning of the post).
Update: our Oracle Java 7 installer now supports ARM. Oracle Java 7 supports ARM v6/v7 Hard Float and Soft Float ABI.
Update: our Oracle Java 7 installer now supports ARM. Oracle Java 7 supports ARM v6/v7 Hard Float and Soft Float ABI.
Update 2: Oracle Java 8 (stable) was released. For how to install it, see:
- for Ubuntu: Install Oracle Java 8 In Ubuntu Via PPA Repository [JDK8]
- for Debian: How To Install Oracle Java 8 In Debian Via Repository [JDK8]
Install Oracle Java 7 in Ubuntu or Linux Mint via PPA
This package provides Oracle Java JDK 7 (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 JDK7 package.
Important: Ubuntu 13.10 and older versions are no longer supported by Canonical: there will be no security updates and they don't allow uploading new packages to Launchpad PPAs!
Important: Ubuntu 13.10 and older versions are no longer supported by Canonical: there will be no security updates and they don't allow uploading new packages to Launchpad PPAs!
To add our PPA and install the latest Oracle Java 7 in Ubuntu 15.04, 14.10, 14.04 and 12.04 or Linux Mint 17.1, 17 and 13, use the commands below:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Tip: if you're behind a firewall / router that blocks some of the redirects required to download the Oracle Java archive, you can download the JDK tar.gz archive manually and place it under /var/cache/oracle-jdk7-installer - then, installing the "oracle-java7-installer" package will use the local archive instead of trying it to download it itself.
After the installation finishes, if you wish to see if it was successful, you can run the following command:
After the installation finishes, if you wish to see if it was successful, you can run the following command:
java -version
It should return something like this:java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
The package installs all the Java binaries, so you can also try "javac -version" which should return "javac 1.7.0_76" and so on (the "_76" part of the version can be different because I'm constantly updating the PPA with the latest Oracle Java 7 version). The current JDK version in the PPA is Oracle Java 7 Update 76 (7u76).
If for some reason, the Java version in use is not 1.7.0, you can try to run the following command:
sudo update-java-alternatives -s java-7-oracle
Update: the installer now requires you 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-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
Setting Java environment variables
To automatically set up the Java 7 environment variables, you can install the following package:
sudo apt-get install oracle-java7-set-default
If you've already installed oracle-java6-set-default or oracle-java8-set-default, they will be automatically removed when installing oracle-java7-set-default (and the environment variables will be set for Oracle Java 7 instead).
Removing Oracle Java 7
If you don't want to use Oracle Java (JDK) 7 anymore on your Ubuntu / Linux Mint computer and want to go back to OpenJDK, all you have to do is remove the Oracle JDK7 Installer and the previous Java (OpenJDK, etc.) version will be used:
sudo apt-get remove oracle-java7-installer
Update: for Debian, see: How To Install Oracle Java 7 In Debian Via Repository
The package is based on Bruce Ingalls' Java Update script and on the flashplugin-installer debian package - thanks!