I added JAVA_HOME & Java path in my .bashrc file. I can see the value once I execute the following command:
$ echo $JAVA_HOME
/usr/lib/jdk/java-8-openjdk/
I have also added my JAVA_HOME in hadoop-env.sh file.
export JAVA_HOME="/usr/lib/jdk/java-8-openjdk/"
But still when I am executing the hadoop namenode -format, I am getting the below error
$ hadoop namenode -format
Warning: $HADOOP_HOME is deprecated.
/usr/bin/hadoop: line 320: /usr/lib/jdk/java-8-openjdk/bin/java: No such file or directory
/usr/bin/hadoop: line 390: /usr/lib/jdk/java-8-openjdk/bin/java: No such file or directory