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
Related
I'm using Eclipse ScalaIDE and for some reason I'm not able to
import scala.io.StdIn
I'm getting a red squiggly that tells me:
object StdIn is not a member of package io
And I'm seeing that it's not in that scala.io jar file. The ScalaDoc, however says it should be there. I've tried both scala 2.10.4 and 2.11.5. I've used the Eclipse ScalaIDE to create the scala project and I've also created an sbt eclipse project directly using the scalasbt.plugin which I use all the time to manage ScalaIDE dependencies.
sbt "eclipse with-source=true"
Neither way is getting it.
I'm currently taking the Coursera Reactive Programming course and an assignment file has this import. I'm able do compile the project with sbt directly, but Eclipse ScalaIDE is not doing the job. Any clues? There may be good reason why not to use scala.io.StdIn, but my question is why can I not get it to import in the ScalaIDE?
thank you
scala.io.StdIn is new in scala 2.11.x and does not exist in previous versions.
The problem you are likely encountering is that ScalaIDE is not picking up the scala version you are specifying. Since you say that you tried it with 2.10.4, it probably still has that cached or set somewhere and it's failing because it cannot find the specified class.
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.
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.
I have recently started exploring Scala.
I have installed Eclips and I integrated Akka-Actors Libs in the Build-Path Project.
But whenever I try compiling the project, I got an erorr. I can't resolve such libraries.
import akka.routing.{Routing, CyclicIterator}
import Routing._
Any idea how to configure Akka to work perfectly with Eclips ?
AFAICT, there's no such class in Akka.
Router, yes - Routing, no.
I have the same problem, I have Added the akka-actor_2.10-2.3.0.jar and the config-1.0.2.jar libraries but the error persists.
In the webpage of akka (akka.io) they use both imports in a example proyect.
http://doc.akka.io/docs/akka/1.3/intro/getting-started-first-scala.html
package akka.tutorial.first.scala
import akka.actor.{Actor, PoisonPill}
import Actor._
import akka.routing.{Routing, CyclicIterator}
import Routing._
.....
.....
....
ANSWER: You should use spray and the spray's library, it has a routing method you can use aswell.
import spray.routing._
You have to download the spray-routing-1.2.0.jar if you want to use it (http://repo.spray.io/io/spray/spray-routing/)
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.