0

My Scala program:

import org.apache.spark._
import org.apache.spark.SparkContext._

object WordCount {
    def main(args: Array[String]) {
      val inputFile = args(0)
      val outputFile = args(1)
      val conf = new SparkConf().setAppName("wordCount")
      // Create a Scala Spark Context.
      val sc = new SparkContext(conf)
      // Load our input data.
      val input =  sc.textFile(inputFile)
      // Split up into words.
      val words = input.flatMap(line => line.split(" "))
      // Transform into word and count.
      val counts = words.map(word => (word, 1)).reduceByKey{case (x, y) => x + y}
      // Save the word count back out to a text file, causing evaluation.
      counts.saveAsTextFile(outputFile)
    }
}

Error I am getting :

Error: Could not find or load main class WordCount
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Harsh
  • 109
  • 1
  • 2
  • 12

2 Answers2

0

You have not set property of master.

val conf = new SparkConf().setAppName("wordCount").setMaster(local[*])
Mahesh Chand
  • 3,158
  • 19
  • 37
0

I think is probably something with the classpath, not correctly set up.

If you're using Intellij, mark that directory as source root, could do the trick.