title: Running code on JAVA app on AWS EMR Master as client mode
body: <p>I am trying to run spark code on AWS EMR master node. But unable to configure the context on Master node. </p>
  
  <pre><code> SparkConf conf = new SparkConf().setAppName("testapp");
   JavaSparkContext sc = new JavaSparkContext(conf);
  </code></pre>
  
  <p>I tried setMaster('yarn') and without master as well. But unable to get it running. </p>
  
  <p>Is it even possible to run Spark code on master node as part of Java App. I have Spring Boot app running on Master node of AWS EMR cluster. </p>
  
  <p>If I run this on another ec2 instance how do I configure this to run on EMR cluster?</p>
  
  <pre><code>@RequestMapping(
  path = "/test/api",
  method = RequestMethod.GET
  )
  public Integer testApi(
  final HttpServletResponse response
  ) {
  
      SparkConf conf = new SparkConf().setAppName("testApp");
  
      JavaSparkContext sc = new JavaSparkContext(conf);
  
      JavaRDD&lt;String&gt; lines = sc.textFile("test.txt");
      JavaRDD&lt;String&gt; numbers = lines.flatMap(line -&gt; Arrays.asList(line.split("\\s+")).iterator());
  
      JavaRDD&lt;String&gt; validNumbers = numbers.filter(number -&gt; !number.isEmpty());
  
      JavaRDD&lt;Integer&gt; intNumbers = validNumbers.map(number -&gt; Integer.valueOf(number));
  
      return intNumbers.reduce((x, y) -&gt; x + y);
  }
  </code></pre>