10

When importing the following in Eclipse Scala-IDE

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

I get this error: Object spark is not a member of package org

I installed the sbt-0.13.9.msi

What else should I do?

build.sbt

name := "scala-spark-app"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies += "org.apache.spark" %% "spark-core" % "1.5.2"
javaPlease42
  • 4,699
  • 7
  • 36
  • 65
Adham
  • 111
  • 1
  • 1
  • 5
  • How did you create this project? Does the problem exist when you simply run `sbt package`? – zero323 Nov 26 '15 at 23:53
  • 2
    It the error message literally "Object spark is not a member of package org"? Did you maybe somewhere type `org.spark` instead of `org.apache.spark`? – Jesper Nov 27 '15 at 07:42
  • C:\Users\Adham>sbt package Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [info] Set current project to adham (in build file:/C:/Users/Adham/) [success] Total time: 0 s, completed 27-Nov-2015 19:10:51 – Adham Nov 27 '15 at 16:12
  • 1
    Why it is so complicated to use/setup Scala, setting up Java is very easy, just install eclipse and the JDK and you are done! – Adham Nov 27 '15 at 16:39
  • Are you on mac or linux? Go to your project directory (where your build.sbt file lives), type `sbt compile`. Does everything work ok? – marios Nov 28 '15 at 02:09
  • Compling succeed but when I ran the .scala file I still get problems C:\Users\Adham\ScalaWorkSpace\Chapter1>sbt compile Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 [info] Set current project to scala-spark-app (in build file:/C:/Users/Adham/ScalaWorkSpace/Chapter1/) [success] Total time: 5 s, completed 30-Nov-2015 12:25:30 – Adham Nov 30 '15 at 09:39
  • in linux: adhem@adhem-ThinkPad-E520:~/workspace/Chapter1$ sbt compile [info] Loading project definition from /home/adhem/workspace/Chapter1/project/project [info] Loading project definition from /home/adhem/workspace/Chapter1/project [info] Set current project to scala-spark-app (in build file:/home/adhem/workspace/Chapter1/) [success] Total time: 0 s, completed Dec 1, 2015 11:13:39 PM – Adham Dec 01 '15 at 20:14
  • in windows and in linux the problem is the same! – Adham Dec 01 '15 at 20:14

1 Answers1

3

I was receiving the same compilation error (on my Mac) with IntelliJ whereas sbt compile executed successfully. The following steps solved my problem:

  1. sbt clean
  2. sbt gen-idea (to rebuild IntelliJ project files)
  3. quit and restart IntelliJ

I hope this helps.

laylaylom
  • 1,754
  • 16
  • 15