configure run in eclipse for Scala

Solution 1:

If you want to run the whole project it should have a "main class", in any of your Scala objects you should be defining:

def main(args:Array[String]) { <some nice code here> }

From there it should be "calling" the rest of your objects to do whatever the whole project does and in the "Class Main" column you should specify the fully qualified name of your object. For instance, if you defined the main in a class called "Start" in the package "starter", in the "Class Main" field you should state "starter.Start".

But on the other hand if you only want to run a Scala object it should extend App, if it doesn't extend App, Scala IDE won't add the "Run as Scala Application...":

package greeter
object Hello extends App {
  println("Hello, World!")
}

Solution 2:

Right click your project and check the "Scala Compiler" settings. Check the "Project Specific" checkbox and try checking if you can run your Scala object (which should extend App).

Solution 3:

make sure your declared package in your source code matches the directory structure under your source directory.

in this case, a sourcefile declaring package "greeter" will auto-run as scala if the source file is indeed under src/greeter/Hello.scala (and not just under src/Hello.scala)

Its a common mistake that doesn't get highlighted by the syntax checker.