4

I've the following build.sbt file:

name := "Stocks"

version := "1.0"

scalaVersion := "2.10.2"

resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor"   % "2.2.3",
  "com.typesafe.akka" %% "akka-slf4j"   % "2.2.3",
  "com.typesafe.akka" %% "akka-remote"  % "2.2.3",
  "com.typesafe.akka" %% "akka-agent"   % "2.2.3",
  "com.typesafe.akka" %% "akka-testkit" % "2.2.3" % "test"
)

When I import akka._ in a .scala file I'm getting the error:

[error] /home.......stocks/src/main/scala/main.scala:3: not found: object akka
[error] import akka._

Why?

2
  • 2
    I just tried this, and it works. Are you launching sbt from the right directory (the root of the project, which should be where the build.sbt file is)? Feb 1, 2014 at 21:33
  • 1
    Sir, your karma just improved considerably, somewhere I must have missed that the build.sbt file should be in the top and not anywhere else. Thanks!
    – ROAR
    Feb 1, 2014 at 21:39

1 Answer 1

7

The directory structure needs to look like this:

.
├── build.sbt
└── src
    └── main
        └── scala
            └── main.scala

And you have to launch sbt from the project's root directory (where the build.sbt file is).


Side note: If were to use a Scala build configuration instead of build.sbt, that would go in the project directory instead.

.
├── project
│   └── Build.scala
└── src
    └── main
        └── scala
            └── main.scala
1
  • What does this mean exactly. I'm having the same exact problem right now. Does the location of my build.sbt matter?
    – JPG
    Aug 6, 2019 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.