title: Passing Arguments in Apache Spark
body: <p>I am running this code on a local machine: </p>
  
  <pre><code>import org.apache.spark.SparkContext
  import org.apache.spark.SparkContext._
  import org.apache.spark.SparkConf
  
  object SimpleApp {
    def main(args: Array[String]) {
      val logFile = "/Users/username/Spark/README.md"
      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'd like to run the program but run it on different files - it currently only runs on README.md. How do I pass the file path of another file when running Spark (or any other argument for that matter?). For example, I'd like to change <code>contains("a")</code> to another letter.</p>
  
  <p>I make the program run by:</p>
  
  <pre><code>$ YOUR_SPARK_HOME/bin/spark-submit \
    --class "SimpleApp" \
    --master local[4] \
    target/scala-2.10/simple-project_2.10-1.0.jar
  </code></pre>
  
  <p>Thanks!</p>