title: spark & java COMPILATION ERROR
body: <p>When I used maven to compile spark java program, I got an compilation error like this</p>
  
  <pre><code>[ERROR] COMPILATION ERROR : 
  [INFO] -------------------------------------------------------------
  [ERROR] /home/spark/java/src/main/java/SimpleApp.java:[9,36] cannot find symbol
    symbol:   variable read
    location: variable spark of type org.apache.spark.sql.SparkSession
  </code></pre>
  
  <p>here is my JAVA pragram</p>
  
  <pre><code>import org.apache.spark.sql.SparkSession;
  import org.apache.spark.sql.Dataset;
  
  
  public class SimpleApp {
    public static void main(String[] args) {
      String logFile = "/home/spark/spark-2.2.0-bin-hadoop2.7/README.md"; // Should be some file on your system
      SparkSession spark = SparkSession.builder().appName("Simple Application").getOrCreate();
      Dataset&lt;String&gt; logData = spark.read.textFile(logFile).cache();
  //    Dataset&lt;String&gt; logData = SparkSession.builder().appName("Simple Application").getOrCreate().read.textFile(logFile).cache();
      long numAs = logData.filter(s -&gt; s.contains("a")).count();
      long numBs = logData.filter(s -&gt; s.contains("b")).count();
  
      System.out.println("Lines with a: " + numAs + ", lines with b: " + numBs);
  
      spark.stop();
    }
  }
  </code></pre>
  
  <p>I write the program follow the  official website :
  <a href="http://spark.apache.org/docs/latest/quick-start.html" rel="nofollow noreferrer">http://spark.apache.org/docs/latest/quick-start.html</a>
  how this error comes..??  </p>
  
  <p>here is my pom.xml</p>
  
  <pre><code>&lt;project&gt;
    &lt;groupId&gt;edu.berkeley&lt;/groupId&gt;
    &lt;artifactId&gt;simple-project&lt;/artifactId&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;name&gt;Simple Project&lt;/name&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;version&gt;1.0&lt;/version&gt;
    &lt;properties&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
    &lt;/properties&gt;
  
    &lt;dependencies&gt;
      &lt;dependency&gt; &lt;!-- Spark dependency --&gt;
        &lt;groupId&gt;org.apache.spark&lt;/groupId&gt;
        &lt;artifactId&gt;spark-sql_2.11&lt;/artifactId&gt;
        &lt;version&gt;2.2.0&lt;/version&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>