private String getJavaHome() {
    String javaHome = cl.getJavaPath();
    if (StringUtils.isEmpty(javaHome)) {
      javaHome = System.getenv("JAVA_HOME");
      String jreHome = System.getProperty("java.home");
      if (javaHome == null) {
        javaHome = jreHome;
      } else if (!javaHome.equals(jreHome)) {
        LOG.warn("Java versions might not match : JAVA_HOME=[{}],process jre=[{}]", javaHome, jreHome);
      }
    }
    if (StringUtils.isEmpty(javaHome)) {
      throw new RuntimeException(
          "Could not determine JAVA_HOME from command line parameters, environment or system properties");
    }
    LOG.info("Using [{}] for JAVA_HOME", javaHome);
    return javaHome;
  }
This is a working configuration for the instance to merge various variables.
It is not written out for llap server usage
llap-server/src/java/org/apache/hadoop/hive/llap/cli/service/LlapServiceDriver.java