title: Get EMR Cluster ID inside Java Spark application
body: <p>I have Spark application written in Java and executing it via AWS EMR. I want to get the ID of the EMR cluster inside my Java code. I have tried using below:</p>
  <p><code>String emrClusterID = System.getenv(&quot;EMR_CLUSTER_ID&quot;);</code></p>
  <p>but it returns <code>null</code> cluster ID. I do not want to use the EMR APIs to get the list of running clusters and then get the ID from there because I do not know inside the code what is the cluster name and there can be multiple clusters in Running state with the same name. So, how can I get the cluster ID of the running cluster from inside the code in Spark Java application?</p>