Ubuntu / Linux news and application reviews.

Oracle Java logo

Because I've received quite a few requests for this, you can now install the latest Oracle Java 9 (early access release) in all supported Ubuntu / Linux Mint versions, by using the WebUpd8 Oracle Java PPA.

For now, you should continue to use Java 8 because Oracle Java 9 is available as an early access release (it should be released in 2016)! You should only use Oracle Java 9 if you explicitly need it, because it may contain bugs and it might not include the latest security patches! Also, some Java options were removed in JDK9, so you may encounter issues with various Java apps.

Reminder: the WebUpd8 Oracle Java PPA doesn't include any Oracle Java binaries because that's not allowed by the Oracle Java license, that's why the PPA provides an installer that automatically downloads the latest Oracle Java 9 (JDK9 and the Java 9 browser plugin) and sets up everything for you. Also, the Oracle Java 9 Installer is considered to be alpha quality and is offered without any guarantees, so use it at your own risk!

It's also important to mention that the Oracle Java 9 download servers are pretty slow (and it's even slower to start), so even with a fast Internet connection, the download may take a while or it may fail (so you'll have try again) and there's nothing I can do about that.

If you want to install Oracle Java 8 instead (which is considered stable), see these articles: Ubuntu / Linux Mint | Debian.


Install Oracle Java 9 (JDK9) in Ubuntu, Linux Mint or Debian via PPA


To add the WebUpd8 Oracle Java PPA and install Oracle Java 9 in all supported Ubuntu / Linux Mint versions (note: ARM is not yet supported), use the following commands:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java9-installer

To install Oracle Java 9 in Debian, you can setup "add-apt-repository" as we've explained a while back and use the Ubuntu installation instructions above. You can also manually add the repository and key and install Oracle Java 9 in Debian using the following commands:
su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-get update
apt-get install oracle-java9-installer
exit

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-jdk9-installer - then, installing the "oracle-java9-installer" package will use the local archive instead of trying it to download it itself.

After installing the package, you can check the Java version by running "java -version" in a terminal, which should display an output similar to this:
andrei@andrei-desktop:~$ java -version
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b50)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b50, mixed mode)
Or, "javac -version":
andrei@andrei-desktop:~$ javac -version
javac 1.9.0-ea
And so on.


Automated installation (auto accept license)


The Oracle Java 9 Installer prompts you to accept the Oracle license before proceeding with the installation and it's only required once, so you don't have to accept the license with each update. If you want to automate the installation process, you can use the command below to automatically accept the Oracle Java 9 license:
echo oracle-java9-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 9 environment variables, you can install the following package:
sudo apt-get install oracle-java9-set-default
If you've already installed oracle-java7-set-default or oracle-java8-set-default, they will be automatically removed when installing oracle-java9-set-default (and the environment variables will be set for Oracle Java 9 instead).