2 Ways of installing Java 8 on CentOS

Installing Java on CentOS is one of the easiest exercise ever. However, I’ll let you know two different ways in which Java can be installed on CentOS. We’ll take latest version of Java which is Java 8. Even you can combine all following steps in one shell script and can simply execute that shell script in order to install Java/JDK. Following steps are performed using root user you can also execute the steps with non root user having sudoer rights. Before moving towards installation process I have assumed that CentOS has wget command installed. If not than install it using below step.

Note: Refer my post How to setup Passwordless SSH with non root users in CentOS to know how to create non root user in linux.

Ways of Installation

  • Tarball Instllation
  • RPM Instllation

Download Tar OR RPM file of Java 8 using below commands


For Tarball Install,  Extract & Move jdk1.8.0_40 directory under <em>/usr/java/</em> directory

For RPM Install, Extract RPM file with following command

Than after All subsequent Commands are same 🙂

Configure java, javac, jar, jps and javaws commands using alternatives

Note: alternatives is a command in linux which is used to create, maintain, remove and displays information related to the symbolic links comprising the alternatives system. Click here to read more about alternatives

Check Java version

 Update JAVA_HOME and PATH for all users in any of below files

<em>/etc/profile</em> (Global for all users)

<em>~/.bash_profile</em> (User specific)

That’s it we are done with this simplest steps of installation of Java 8 on CentOS….!!!!!

Leave a Reply

Notify of