@Lucky_Luke
If you are managing your cluster via Ambari then the easiest option is to setg the JAVA_HOME via abari setup command.
That way ambari will pass the JAVA_HOME variable to variaou components during their startup and your whole cluster components will be using the same path for Java_home.
You can find the java home property inside ambari's
# grep 'java.home' /etc/ambari-server/conf/ambari.properties
.
Ambari also allows you to choose a custom JDK then you can refer to the following DOC: https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.2.0/bk_ambari-administration/content/ch_changin...
If you choose Custom JDK, verify or add the custom JDK path on all hosts in the cluster. Use this option if you want to use OpenJDK or do not have an internet connection (and have pre-installed the JDK on all hosts).
You must install this JDK on all hosts in the cluster to this same path on all hosts.
.
Using command line via Amabri setup:
# ambari-server setup -j /path/to/your/installed/jdk
Although you can manage the JAVA_HOME path on every host using "/etc/profile" file however it is best from maintenance perspective to delegate this task to Ambari.
Reference:
https://community.hortonworks.com/questions/109575/setuping-ambari-with-existing-jdk-cause-issues.ht...