title: convert RDD to Dataset in Java Spark
body: <p>I have an RDD, i need to convert it into a Dataset, i tried:</p>
  
  <pre><code>Dataset&lt;Person&gt; personDS =  sqlContext.createDataset(personRDD, Encoders.bean(Person.class));
  </code></pre>
  
  <p>the above line throws the error,</p>
  
  <blockquote>
    <p>cannot resolve method createDataset(org.apache.spark.api.java.JavaRDD
    Main.Person, org.apache.spark.sql.Encoder T)</p>
  </blockquote>
  
  <p>however, i can convert to <code>Dataset</code> after converting to <code>Dataframe</code>. the below code works:</p>
  
  <pre><code>Dataset&lt;Row&gt; personDF = sqlContext.createDataFrame(personRDD, Person.class);
  Dataset&lt;Person&gt; personDS = personDF.as(Encoders.bean(Person.class));
  </code></pre>