Reputation: 64207
I've created an SBT 0.11 project of an only one source code file (yet):
object HelloWorld extends App {
println("Hello, world!")
}
When try to run
the application with SBT, I get "java.lang.RuntimeException: No main class detected".
How do I define the main class?
I have used "full configuration" with the folowing Build.scala
:
import sbt._
object MyBuild extends Build {
lazy val HelloWorld = Project("HelloWorld ", file("src"))
}
And the following build.sbt
:
name := "HelloWorld"
version := "1.0"
scalaVersion := "2.9.1"
Upvotes: 2
Views: 3498
Reputation: 297185
Project
's second parameter indicate what is the base directory of that project, which assumes you have many projects. If the path to your source code was HelloWorld\src\src\main\scala\HelloWorld.scala
, then that original line would work.
The thing is... that second parameter does not point to the source code. It points to the project. For example, you'd see it probably created the directory HelloWorld\src\target
at the time you tried to use the original configuration.
Upvotes: 2
Reputation: 105220
Try replacing:
lazy val HelloWorld = Project("HelloWorld ", file("src"))
with:
lazy val HelloWorld = Project("HelloWorld ", file("."))
Upvotes: 2