How to install JAVA jdk 1.8 on CentOS 7 linux server

Java is popular language since last decade many softwares are designed on java and make use of java to run. Some application like tomcat and Jboss make use of java to run various applications are based on java. You need to install the java on linux server if you want to run any tomcat application or jboss application on the linux server. There are various terms related to java like JRE, JDK, JVM and Open JDK.

What is JRE

JRE is known as Java Runtime Environment This helps to run application and servlets which are developed in the Java language. JRE includes browser plugins JVM and necessary tools to run and support Java language

What is JDK

JDK is java development kit which is superset of toolkit provided by java and includes JRE in it. JDK also includes the java compiler called as javac is which is used to compile and create java jar files

What is JVM

JVM is java virtual machine which runs the java application code. This java code is converted to bytecode by JVM and runs that compiled code.

What is OpenJDK

Java is developed and managed by Oracle corporation. Java also have its open source version which is maintained by OpenJDK. There is no appearance difference between oracle java and openjdk java.

How to install JDK 1.8 on CentOS 7 server

JDK can be downloaded from offcial java website. You can simple wget the file on the server via shell wget command

cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz"
tar xzf jdk-8u121-linux-x64.tar.gz

Use alternative tool for Java

 alternative tool is part of chkconfig package which is available by default on CentOS 7 minimal installations.

cd /opt/jdk1.8.0_121/
alternatives --install /usr/bin/java java /opt/jdk1.8.0_121/bin/java 2
alternatives --config java

config command lists all the java version installed on the server you can select the version which is showing as /opt/jdk1.8.0 Once you selected that JAVA is installed successfully on your server.  There are various variables are used in java software we will not set those variable values also using below commands

alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_121/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_121/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_121/bin/jar
alternatives --set javac /opt/jdk1.8.0_121/bin/javac

Now Java 1.8 or also called as JAVA 8 is installed on your server.

Leave a Comment