Following are the simple steps for setting the JAVA (JDK) JAVA_HOME and PATH in Unix

Note: Considering the java have installed in /opt/jdk1.7.0_79 or you can download form
A. To set the environment variables:
echo ‘export JAVA_HOME=/opt/jdk1.7.0_79′ > /etc/profile.d/
echo ‘export PATH=$JAVA_HOME/bin:$PATH’ >> /etc/profile.d/

B. What we need now to source the file we have created in above command /etc/profile.d/
source /etc/profile.d/

C. Done for use, type as mention below in any Unix  terminal:

java -version
java version "1.7.0_79"
Java (TM) SE Runtime Environment (Build 1.7.0_79-b15)


Please provide your input, it will honer for me...