I am new to Scala.
I have downloaded the Scala Eclipse IDE, and started to write a new program using akka and actors, and I am trying to import akka as follows,
import akka.actor._
but am getting the errors as follows,
Multiple markers at this line
- not found: object akka
- object actor is not a member of
package akka
I want to know why I am getting this error, do I need to add any other packages ?
You need to add a dependency to the akka-actor jar. "Getting started" section of the Akka documentation http://doc.akka.io/docs/akka/snapshot/intro/getting-started.html has more information on which jars to add.
Related
I am writing a toy Akka example to get some understanding of the concepts. I am having trouble importing the akka model into my project in intelij.
I am making the below import statement
import akka.actor.Actor
The error messgae reads
cannot resolve the symbol Akka
Is there an additional step to working with akka that I have missed ?
Why does the compiler not recognise the import ?
You have to add Akka dependency to your build.sbt
https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor_2.11/2.5.18
Then you should reimport the dependency, using sbt tool in your ide as mentioned here: https://stackoverflow.com/a/20466144/2201566
I am receiving error while building my spark application (scala) in IntelliJ IDE.
It is a simple application with uses Kafka Stream for further processing. I have added all the jars and the IDE does not show any unresolved import or code statements.
However, when I try to build the artifact, I get two errors stating that
Error:(13, 35) object kafka is not a member of package
org.apache.spark.streaming
import org.apache.spark.streaming.kafka.KafkaUtils
Error:(35, 60) not found: value KafkaUtils
val messages: ReceiverInputDStream[(String, String)] = KafkaUtils.createStream(streamingContext,zkQuorum,"myGroup",topics)
I have seen similar questions but most of the ppl complain about this issue while submitting to spark. However, I one step behind that and merely building the jar file which would be submitted ultimately to spark. On top I am using IntelliJ IDE and a bit new to spark and scala; lost here.
Below is the snapshot of the IntelliJ Error
IntelliJ Error
Thanks
Omer
The reason is that you need to add spark-streaming-kafka-K.version-Sc.version.jar to your pom.xml and as well as your spark lib directory.
I am using Scala on Eclipse Luna and trying to connect to Cassandra. My code is showing the error apache object is not a member of package org on the following line:
import org.apache.spark.SparkConf
I already imported the Scala and Spark libraries into the project. Does someone know how can I make my program import Spark libraries?
Does anybody have any experience with trying to get swing to work in eclipse, I can import it fine into scala using the command line interface, but when i try and use it in an eclipse scala project I get the following error:
import scala.swing._
"object swing is not a member of package scala"
Any help would be much appreciated.
If you are missing the library (as RĂ¼diger said, it is a separate dependency now), you can find how to add it to your build system here (for Scala 2.11):
http://search.maven.org/#artifactdetails|org.scala-lang.modules|scala-swing_2.11|1.0.1|bundle
Look under "Dependency Information", e.g. for sbt if you use that.
The Scala 2.10 release notes says this: "Akka Actors now part of the distribution. The original Scala actors are now deprecated."
The latest Akka library ("Akka 2.1.0 for Scala 2.10") mentions the following dependency:
com.typesafe.akka:akka-actor_2.10:2.1.0
and the following examples:
import akka.actor.Actor
class MyActor extends Actor {..}
val system = ActorSystem("MySystem")
My project includes these libraries:
org.scala-lang:scala-library:2.10.0
org.scala-lang:scala-actors:2.10.0
In my classpath, I have no package called "akka". I do see instead scala.actors, but it doesn't seem deprecated.
So, in which way are Akka Actors "part of the distribution"?
If this is, indeed, the case, then am I still supposed to add the "akka-actor_2.10" library as a dependency? If so, do I use akka.Actor or the non-deprecated scala.actors.Actor ?
In scala 2.9.2 scala actors was part of scala-library.jar.
If you download a scala-2.10.0 distribution it there are no actors in scala-library and both akka-actors.jar and scala-actors.jar are supplied.
The latter is present for backwards compatibility and will be removed in a future major release.
akka-actors is the replacement and what you should use for any new development (and look to move anything using scala-actors across when possible).
If you have no current code in your project using actors you should probably reconfigure your project's dependencies to remove org.scala-lang:scala-actors:2.10.0 and instead depend on com.typesafe.akka:akka-actors_2.10:2.1.0 if you want to use actors.
I am not sure why there's no deprecation annotation on the classes in scala-actors in 2.10.0 but I believe it's to be added in 2.10.1.
You can find more info on the migration guide.