How to Install Java JDK9 on Linux Mint 18.3

To Install Java JDK9 on Linux Mint 18.3
Java is a cross-platform program and it' s used by several developers to build applications and websites. Due to its speed, reliability, and safety. Currently, Java 10, the latest version of the program is gaining more popularity.   After several months of testing, Java 9 was finally rolled out in September 2017 and is available on all platforms with newer features and improvements. In this tutorial, you will be briefed about the method to install Java JDK9 on Linux Mint 18.3. 


Installing Java JDK9

If you' re running Ubuntu, Linux  Mint or Debian, you can install JDK 9 using the apt utility for Debian-based operating systems. Java JDK 9 for Debian based distros is hosted on the webupd8 repository and we' ll  be installing it from there.

linuxhelp ~ # add-apt-repository ppa:webupd8team/java

You are about to add the following PPA:

 Oracle Java (JDK) Installer (automatically downloads and installs Oracle JDK7 / JDK8 / JDK9). There are no actual Java files in this PPA.

Important ->  Why Oracle Java 7 And 6 Installers No Longer Work: http://www.webupd8.org/2017/06/why-oracle-java-7-and-6-installers-no.html

Ubuntu 16.10 Yakkety Yak is no longer supported by Canonical (and thus, Launchpad and this PPA). The PPA supports Ubuntu 17.10, 17.04, 16.04, 14.04 and 12.04.

More info (and Ubuntu installation instructions):
- for Oracle Java 7: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
- for Oracle Java 8: http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html

.
.
More info: https://launchpad.net/~webupd8team/+archive/ubuntu/java
Press Enter to continue or Ctrl+C to cancel

Executing: /tmp/tmp.yKcCaHwFMo/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-keys
EEA14886
gpg: requesting key EEA14886 from hkp server keyserver.ubuntu.com
gpg: key EEA14886: public key " Launchpad VLC"  imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

You shall now update your system repository by making use of the following command. 

linuxhelp ~ # apt-get update 
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://archive.canonical.com/ubuntu xenial InRelease                                                                                
Ign:3 http://packages.linuxmint.com sylvia InRelease                                                                                      
Get:4 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial InRelease [17.5 kB]                                    
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]                     
Get:6 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main Sources [1,408 B]                 
Get:7 http://packages.linuxmint.com sylvia Release [24.2 kB]                 
.
.
Get:30 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6,628 B]                                                
Get:31 http://archive.ubuntu.com/ubuntu xenial-backports/universe i386 Packages [6,620 B]                                                 
Fetched 5,038 kB in 9s (528 kB/s)                                                                                                         
Reading package lists... Done

You shall now install the Java 9 package by making use of the following command. 

linuxhelp ~ # apt-get install oracle-java9-installer
Reading package lists... Done
Building dependency tree        ing state information... Done
Suggested packages:
  visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho | ttf-sazanami-mincho
  ttf-arphic-uming

Recommended packages:
.
.
update-alternatives: using /usr/lib/jvm/java-9-oracle/bin/javaws.real to provide /usr/bin/javaws.real (javaws.real) in auto mode
Oracle JDK 9 installed

Although Java has been installed, it is not set as default. You shall run the following command to set it as default. 

linuxhelp ~ # apt install oracle-java9-set-default
Reading package lists... Done
Building dependency tree      
Reading state information... Done

The following NEW packages will be installed:

  oracle-java9-set-default   
0 upgraded, 1 newly installed, 0 to remove and 200 not upgraded.

Need to get 4,482 B of archives.
After this operation, 16.4 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main amd64 oracle-java9-set-default amd64 9.0.4-1~webupd8~0 [4,482 B]
Fetched 4,482 B in 0s (10.4 kB/s)             

Selecting previously unselected package oracle-java9-set-default.

(Reading database ... 223917 files and directories currently installed.)
Preparing to unpack .../oracle-java9-set-default_9.0.4-1~webupd8~0_amd64.deb ...
Unpacking oracle-java9-set-default (9.0.4-1~webupd8~0) ...
Setting up oracle-java9-set-default (9.0.4-1~webupd8~0) ...


You shall also check the version of Java by making use of the following command.

linuxhelp ~ # java --version
java 9.0.4
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)

Now that Java has been installed, you are now required to set up Java Environment run some java applications. Set up the JAVA_HOME environment variable by adding the following lines at the end of /etc/environment file using your favorite text editor:

linuxhelp ~ # export JAVA_HOME=/opt/jdk-9
linuxhelp ~ # export PATH=" $PATH:$JAVA_HOME/bin" 

You shall now Be Removing Java 9 from your Linux system is pretty easy. For Debian-based distros

linuxhelp ~ # apt purge oracle-java9-installer
Reading package lists... Done
Building dependency tree      
Reading state information... Done

The following packages will be REMOVED:


  oracle-java9-installer* oracle-java9-set-default*
0 upgraded, 0 newly installed, 2 to remove and 200 not upgraded.
After this operation, 133 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 223921 files and directories c
.
.
Purging configuration files for oracle-java9-installer (9.0.4-1~webupd8~0) ...
Processing triggers for desktop-file-utils (0.22+linuxmint1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...

With this, the method to  Install Java JDK9 on Linux Mint 18.3 comes to an end.

FAQ
Q
which command to check the java version in ubuntu?
A
you want to view the version of Java, you can use the following command
# java -version
Q
which command to add the repo for installing oracle JDK in ubuntu?
A
add Oracle' s PPA, then update your package repository by following steps
# add-apt-repository ppa:webupd8team/java
# apt-get update
Q
How do I save and exit out of the repo once i have entered the content in?
A
Press [Esc] key and type Shift+ZZ to save file.
Q
what is the purpose of Install Java on Ubuntu?
A
Java and the JVM (Java' s virtual machine) are widely used on many kinds of software. This article will guide you through the process of installing and managing different versions of Java using apt-get.
Q
how to install java runtime environment on ubuntu?
A
this command installs the Java Runtime Environment (JRE).
# apt-get install default-jre