title: spark Type mismatch: cannot convert from JavaRDD<Object> to JavaRDD<String>
body: <p>I have started to write my Pyspark application to Java implementation. I am using Java 8. I just started to execute some of the basic spark progrma in java. I used the following <a href="http://ingini.org/2015/05/04/apache-spark-java-8-streams-overview/" rel="nofollow noreferrer">wordcount</a>  example.</p>
  
  <pre><code>SparkConf conf = new SparkConf().setMaster("local").setAppName("Work Count App");
  
  // Create a Java version of the Spark Context from the configuration
  JavaSparkContext sc = new JavaSparkContext(conf);
  
  JavaRDD&lt;String&gt; lines = sc.textFile(filename);
  
  JavaPairRDD&lt;String, Integer&gt; counts = lines.flatMap(line -&gt; Arrays.asList(line.split(" ")))
                      .mapToPair(word -&gt; new Tuple2(word, 1))
                      .reduceByKey((x, y) -&gt; (Integer) x + (Integer) y)
                      .sortByKey();
  </code></pre>
  
  <p>I am getting <code>Type mismatch: cannot convert from JavaRDD&lt;Object&gt; to JavaRDD&lt;String&gt;</code> error in <code>lines.flatMap(line -&gt; Arrays.asList(line.split(" ")))</code>
  When i googled, in all the Java 8 based spark example, i saw the same above implementation.What went wrong in my environemnt or the program. </p>
  
  <p>Can some one help me ?</p>