In this tutorial we will cover the steps needed to install Java on your CentOS 6.4, Debian or Ubuntu platform.

Requirements

  • CentOS 6.4, Debian or Ubuntu installed on your computer/server
  • SSH access (Command line access to the server)
  • root privileges
  • Basic skills for working on a Linux environment

Install Java Development Kit (JDK) on CentOS 6.4

The latest JDK package can be downloaded from the official website.

Bear in mind that the JDK is specific to 32 and 64 bit versions. In this article we will use 64-bit version. The package will be installed inside a newly created folder /usr/java:

Download and extract the package inside the /usr/java folder:

A folder called jdk1.8.0_05 will be extracted which we will use as Java home folder. In order for the configuration to be saved permanently we should edit the user's ~/.bash_profile file:

Once done you should log out from the current SSH session and then log back again.

Install Java Development Kit (JDK) on Debian/Ubuntu

For the JDK installation we will use the default package manager included inside the corresponding Linux distribution:

After that you will need to set Java home folder. We can do that by editing the file ~/.bashrc and adding the following line inside:

Once done you should log out fro the current SSH session and then log back again.

The Java version can be displayed with the command: