I'm just following akka sample but could not run the program.
- I've installed akka, sbt(0.13), scala(2.10.3) using homebrew(OSX Mountail Lion)
- make empty directory named akka_test
- create build.sbt and Hello.scala file
- run sbt in akka_test directory and compile command worked well
- sbt's run command complains No main class detected
What should I do to run the program?
here's my code
build.sbt
name := "My Project"
version := "1.0"
scalaVersion := "2.10.2"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies +=
"com.typesafe.akka" %% "akka-actor" % "2.2.1"
Hello.scala
import akka.actor.Actor
import akka.actor.Props
class HelloWorld extends Actor {
override def preStart(): Unit = {
// create the greeter actor
val greeter = context.actorOf(Props[Greeter], "greeter")
// tell it to perform the greeting
greeter ! Greeter.Greet
}
def receive = {
// when the greeter is done, stop this actor and with it the application
case Greeter.Done ⇒ context.stop(self)
}
}
object Greeter {
case object Greet
case object Done
}
class Greeter extends Actor {
def receive = {
case Greeter.Greet ⇒
println("Hello World!")
sender ! Greeter.Done
}
}