title: Spark Java Version Errors
body: <p>I am using Spark 2.1.1 Scala 2.11.8 and Java 8</p>
  
  <p>Main Java Spark class:</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
  import java.util.regex.Pattern;
  
  import org.apache.spark.SparkConf;
  import org.apache.spark.streaming.Durations;
  import org.apache.spark.streaming.api.java.JavaDStream;
  import org.apache.spark.streaming.api.java.JavaPairDStream;
  import org.apache.spark.streaming.api.java.JavaPairInputDStream;
  import org.apache.spark.streaming.api.java.JavaStreamingContext;
  import org.apache.spark.streaming.kafka.KafkaUtils;
  
  import kafka.serializer.StringDecoder;
  import scala.Tuple2;
  
  public class SparkSample {
  
       private static final Pattern SPACE = Pattern.compile(" ");
  
      public static void main(String[] args) throws Exception{
  
          SparkConf sparkConf = new SparkConf().setAppName("App");
  
          //Duration the interval at which streaming data will be divided into batches
          JavaStreamingContext javaStreamingContext = new     JavaStreamingContext(sparkConf, Durations.seconds(10));
  
          Set&lt;String&gt; topicsSet = new HashSet&lt;&gt;(Arrays.asList("MY-TOPIC".split(",")));
          Map&lt;String, String&gt; kafkaConfiguration = new HashMap&lt;&gt;();
          kafkaConfiguration.put("metadata.broker.list", "MYIP:9092");
          kafkaConfiguration.put("group.id", "Stream");
  
          JavaPairInputDStream&lt;String, String&gt; messages = KafkaUtils.createDirectStream(
              javaStreamingContext,
              String.class,
              String.class,
              StringDecoder.class,
              StringDecoder.class,
              kafkaConfiguration,
              topicsSet
      );
          messages.print();
          //BELOW PART THROWS ERRORS IF UNCOMMENTED
          //JavaDStream&lt;String&gt; lines = messages.map(Tuple2::_2);
          //JavaDStream&lt;String&gt; words = lines.flatMap(x -&gt;     Arrays.asList(SPACE.split(x)).iterator());
          //JavaPairDStream&lt;String, Integer&gt; wordCounts = words.mapToPair(s -&gt; new Tuple2&lt;&gt;(s, 1))
          //    .reduceByKey((i1, i2) -&gt; i1 + i2);
          //wordCounts.print();
  
          // Start the computation
          javaStreamingContext.start();
          javaStreamingContext.awaitTermination();
      }
  
  }
  </code></pre>
  
  <p>Dependencies:</p>
  
  <pre class="lang-xml prettyprint-override"><code>  &lt;dependencies&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;junit&lt;/groupId&gt;
    &lt;artifactId&gt;junit&lt;/artifactId&gt;
    &lt;version&gt;4.12&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
  &lt;/dependency&gt;
   &lt;dependency&gt;
    &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
    &lt;artifactId&gt;spark-core_2.11&lt;/artifactId&gt;
    &lt;version&gt;2.1.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
      &lt;artifactId&gt;spark-streaming-kafka_2.11&lt;/artifactId&gt; &lt;!-- spark-streaming-kafka_2.11 spark-streaming-kafka-0-8_2.11--&gt;
      &lt;version&gt;1.6.3&lt;/version&gt; &lt;!-- 1.6.3 2.0.1--&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
      &lt;artifactId&gt;spark-streaming_2.11&lt;/artifactId&gt;
      &lt;version&gt;2.1.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
      &lt;artifactId&gt;kafka-clients&lt;/artifactId&gt;
      &lt;version&gt;0.8.2.2&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.kafka&lt;/groupId&gt;
      &lt;artifactId&gt;kafka_2.11&lt;/artifactId&gt;
      &lt;version&gt;0.8.2.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p></p>
  
  <p>The code that is commented throws the following error when uncommented: </p>
  
  <pre><code>Unsupported major.minor version 52.0
  </code></pre>
  
  <p>If I keep it commented then it prints messages just fine. Any ideas why? I am building/compiling with Java 8. </p>