How to install Oracle Java Series (JAVA 9, JAVA 8, JAVA 7, JAVA 6) via PPA in Ubuntu & Mint

Oracle JAVA series (Oracle JAVA 6, Oracle JAVA 7, Oracle JAVA 8, Oracle JAVA 9) installation quit easy for Ubuntu/Mint system via Wepupd8 PPA. JAVA is mandatory to run certain applications in Linux and windows machine.

JAVA comes with two packages (JDK & JRE). JDK stands for (Java Development Kit) which helps developers for developing, debugging, and monitoring Java applications. JRE stands for (Java Runtime Environment) which deploys Java applications on servers.

It includes tools for JVM monitoring and tools commonly required for server applications. Oracle JAVA 9 not yet released officially but we can install via PPA. Don’t install Oracle JAVA 9 in production environment because it may contain bugs and it might not include the latest security patches.

The Wepupd8 team didn’t add any binary for Oracle JAVA installation and they made a script to download the Oracle JAVA from Oracle website and install it straight away. So whenever Oracle will release the update, you can simple upgrade via package manager.

1) Install Oracle via PPA

We can easily install Oracle JAVA 6, Oracle JAVA 7, Oracle JAVA 8, Oracle JAVA 9 to Ubuntu & Mint systems via Webupd8 PPA.

[Adding Oracle PPA]
$ sudo add-apt-repository ppa:webupd8team/java

[Update repository list]
$ sudo apt-get update

[Install Oracle JAVA 9]
$ sudo apt-get install oracle-java9-installer

[Install Oracle JAVA 8]
$ sudo apt-get install oracle-java8-installer

[Install Oracle JAVA 7]
$ sudo apt-get install oracle-java7-installer

[Install Oracle JAVA 6]
$ sudo apt-get install oracle-java6-installer

2) Install Oracle License

To install any of the Oracle product, we should accept the license agreement before proceeding the product installation, The Wepupd8 team created the script to automatically accept the Oracle license by running below command.

[Oracle JAVA 9 License installation]
$ echo oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

[Oracle JAVA 8 License installation]
$ echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

[Oracle JAVA 7 License installation]
$ echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

[Oracle JAVA 6 License installation]
$ echo oracle-java6-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

3) Switching between Oracle Java versions

Say for example, you have already installed Oracle JAVA 6 and you want to switch other Oracle JAVA version such as Oracle JAVA 7, Oracle JAVA 8 & Oracle JAVA 9 you can easily switch using the below commands but make sure all the Oracle packages should have installed on your system.

[Switching Oracle JAVA 9]
$ sudo update-java-alternatives -s java-9-oracle

[Switching Oracle JAVA 8]
$ sudo update-java-alternatives -s java-8-oracle

[Switching Oracle JAVA 7]
$ sudo update-java-alternatives -s java-7-oracle

4) Setting up Java environment variables

To automatically set up the Oracle Java environment variables based on your version, Simply run the below commands.

[Setting up Oracle Java 9 as a Java environment variables]
$ sudo apt-get install oracle-java9-set-default

[Setting up Oracle Java 8 as a Java environment variables]
$ sudo apt-get install oracle-java8-set-default

[Setting up Oracle Java 7 as a Java environment variables]
$ sudo apt-get install oracle-java7-set-default

[Setting up Oracle Java 6 as a Java environment variables]
$ sudo apt-get install oracle-java6-set-default

5) Removing Oracle Java

We can easily remove the oracle by running the below commands.

[Removing Oracle Java 9]
$ sudo apt-get remove oracle-java9-installer

[Removing Oracle Java 8]
$ sudo apt-get remove oracle-java8-installer

[Removing Oracle Java 7]
$ sudo apt-get remove oracle-java7-installer

[Removing Oracle Java 6]
$ sudo apt-get remove oracle-java6-installer

Enjoy..)

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...