[Solved] Error: JAVA_HOME is not set and could not be found.

Error: JAVA_HOME is not set and could not be found.

Problem:

Centos7 Install CDH Error: Error: JAVA_HOME is not set and could not be found.

+ local name=log4j.properties
+ '[' '!' -f /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf/log4j.properties ']'
+ mv /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/hbase-conf/log4j.properties /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf
+ for i in '"$HBASE_CONF_DIR"/*'
++ basename /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/hbase-conf/ssl-client.xml
+ local name=ssl-client.xml
+ '[' '!' -f /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf/ssl-client.xml ']'
++ get_default_fs /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf
++ get_hadoop_conf /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf fs.defaultFS
++ local conf=/opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf
++ local key=fs.defaultFS
++ '[' 1 == 1 ']'
++ /opt/cloudera/parcels/CDH-5.14.4-1.cdh5.14.4.p0.3/lib/hadoop/../../bin/hdfs --config /opt/cloudera-manager/cm-5.14.1/run/cloudera-scm-agent/process/ccdeploy_spark-conf_etcsparkconf.cloudera.spark_on_yarn_6447222260596468198/spark-conf/yarn-conf getconf -confKey fs.defaultFS
Error: JAVA_HOME is not set and could not be found.
+ DEFAULT_FS=

Solution:

Use rpm Install jdk

Download jdk-8u201-linux-x64.rpm

chmod 755 jdk-8u201-linux-x64.rpm
rpm -i jdk-8u201-linux-x64.rpm

configure environment variables:

export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
export PATH=$PATH:$JAVA_HOME/bin

Similar Posts: