Following is a footstep by stride guide to install Java on Linux. In this training, we will install Java on Ubuntu. The procedure and install commands remain the same, for different flavors of Linux, or versions of Java.

How to Install Oracle Java on Ubuntu Linux

Step 1) Earlier you beginning with the setting upwardly Java, yous will demand to remove the OpenJDK/JRE from the system.

To do this, use below control-

sudo apt-go purge openjdk-\*

How to Install Java On Ubuntu

You volition be asked for a confirmation. Enter Y

How to Install Java On Ubuntu

Await for quondam for uninstall to complete

Footstep 2) Check whether Ubuntu OS architecture is 32-fleck or 64-flake.

You can do it using the following command-

file /sbin/init

How to Install Java On Ubuntu

Step 3) Download latest Coffee (a zip file e.1000., jdk-eight-linux-x64.tar.gz) from Oracle site-

https://www.oracle.com/java/technologies/javase-downloads.html

How to Install Java On Ubuntu

Accept the License Agreement.

  • Select x86 for 32-bit system
  • Select x64 for 64-chip system
  • Select the tar.gz for Ubuntu
  • Select rpm for Debian based organization

How to Install Java On Ubuntu

Once a download is complete y'all will run across

How to Install Java On Ubuntu

Stride four) In the concluding, navigate to the location of your zip file

How to Install Java On Ubuntu

Extract contents of java nothing file in a directory of your choice.

In this tutorial, nosotros will extract in the Downloads folder itself –

sudo tar -xvf jdk-8u5-linux-i586.tar.gz

How to Install Java On Ubuntu

Enter your password, if asked. The unzip will proceed. Once done you will see the following binder –

How to Install Java On Ubuntu

Step five) Add together the following system variables to the end of /etc/profile file

JAVA_HOME=<Directory where JAVA has been extracted>/jdk1.viii.0 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin consign JAVA_HOME export PATH

To do so –

Enter command

"sudo nano /etc/profile"

How to Install Java On Ubuntu

Enter the arrangement variables

How to Install Java On Ubuntu

Press Command+C to enter into control fashion

How to Install Java On Ubuntu

Press ^+X to Exit

How to Install Java On Ubuntu

Press "Y" to save the changes

Step 6) At present reload surround using a command,

. /etc/profile

How to Install Java On Ubuntu

Step vii) Its time to let Ubuntu know where our JDK/JRE is located.

Copy-paste below lines into a command prompt.

sudo update-alternatives --install "/usr/bin/java" "java" "<Directory where Coffee has been extracted>/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "<Directory where JAVA has been extracted>/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "<Directory where JAVA has been extracted>/bin/javaws" 1

How to Install Java On Ubuntu

Footstep 8) Tell Ubuntu that our installation i.eastward., jdk1.8.0_05 must be the default Java.

Use below commands to practice this-

sudo update-alternatives --set java <Directory where Coffee has been extracted>/bin/java sudo update-alternatives --set javac <Directory where Coffee has been extracted>/bin/javac sudo update-alternatives --fix javaws <Directory where JAVA has been extracted>/bin/javaws

How to Install Java On Ubuntu

Step ix) Test the installation using below command,

java -version

How to Install Java On Ubuntu

A successful installation will show information equally seen in the above screenshot.