错误:找不到或加载主类com.sundogsoftware.spark.RatingsCounte

时间:2019-01-16 07:30:18

标签: scala scala-ide

我不知道这里出了什么问题。运行时,我在Scala IDE中始终收到“错误:找不到或加载主类com.sundogsoftware.spark.RatingsCounter”。

这是我的scala代码

package com.sundogsoftware.spark

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

/** Count up how many of each star rating exists in the MovieLens 100K 
data set. */
object RatingsCounter {

/** Our main function where the action happens */
def main(args: Array[String]) {

// Set the log level to only print errors
Logger.getLogger("org").setLevel(Level.ERROR)

// Create a SparkContext using every core of the local machine, named RatingsCounter
val sc = new SparkContext("local[*]", "RatingsCounter")

// Load up each line of the ratings data into an RDD
val lines = sc.textFile("../ml-100k/u.data")

// Convert each line to a string, split it out by tabs, and extract the third field.
// (The file format is userID, movieID, rating, timestamp)
val ratings = lines.map(x => x.toString().split("\t")(2))

// Count up how many times each value (rating) occurs
val results = ratings.countByValue()

// Sort the resulting map of (rating, count) tuples
val sortedResults = results.toSeq.sortBy(_._1)

// Print each result on its own line.
sortedResults.foreach(println)
 }
}

这是我的项目结构

enter image description here

这是我的跑步配置

enter image description here

这是我选择的scala编译器选项。

enter image description here

现在尝试调试几个小时,似乎没有任何作用。

任何指针都会有所帮助。

1 个答案:

答案 0 :(得分:1)

签出https://wiki.eclipse.org/Eclipse.ini,我不得不在eclipse.ini文件中更改vm arg,并且为我的JRE选项选择了“使用默认JRE(当前为Java SE 8 [1.8.0_172]”)我创建了scala项目。这为我解决了这个错误。

我正在使用OS X,因此我不得不添加

-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home/bin/java

-vmargs上方