title: How to run Scala script using spark-submit (similarly to Python script)?
body: <p>I try to execute a simple Scala script using Spark as described in the <a href="https://spark.apache.org/docs/1.2.0/quick-start.html" rel="noreferrer">Spark Quick Start Tutorial</a>. I have not troubles to execute the following Python code:</p>
  
  <pre><code>"""SimpleApp.py"""
  from pyspark import SparkContext
  
  logFile = "tmp.txt"  # Should be some file on your system
  sc = SparkContext("local", "Simple App")
  logData = sc.textFile(logFile).cache()
  
  numAs = logData.filter(lambda s: 'a' in s).count()
  numBs = logData.filter(lambda s: 'b' in s).count()
  
  print "Lines with a: %i, lines with b: %i" % (numAs, numBs)
  </code></pre>
  
  <p>I execute this code using the following command:</p>
  
  <pre><code>/home/aaa/spark/spark-2.1.0-bin-hadoop2.7/bin/spark-submit hello_world.py
  </code></pre>
  
  <p>However, if I try to do the same using Scala, I have technical problems. In more detail, the code that I try to execute is:</p>
  
  <pre><code>* SimpleApp.scala */
  import org.apache.spark.SparkContext
  import org.apache.spark.SparkContext._
  import org.apache.spark.SparkConf
  
  object SimpleApp {
    def main(args: Array[String]) {
      val logFile = "tmp.txt" // Should be some file on your system
      val conf = new SparkConf().setAppName("Simple Application")
      val sc = new SparkContext(conf)
      val logData = sc.textFile(logFile, 2).cache()
      val numAs = logData.filter(line =&gt; line.contains("a")).count()
      val numBs = logData.filter(line =&gt; line.contains("b")).count()
      println("Lines with a: %s, Lines with b: %s".format(numAs, numBs))
    }
  }
  </code></pre>
  
  <p>I try to execute it in the following way:</p>
  
  <pre><code>/home/aaa/spark/spark-2.1.0-bin-hadoop2.7/bin/spark-submit hello_world.scala
  </code></pre>
  
  <p>As the result I get the following error message:</p>
  
  <pre><code>Error: Cannot load main class from JAR file
  </code></pre>
  
  <p>Does anybody know what I am doing wrong?</p>