score:5

Accepted answer

The main function needs to be inside an object, not a class definition. So instead of this

package main_function_test

class exm {
  def main(args: Array[String]): Unit = {
    println("Hello world")
  }
}

write this:

package main_function_test

object exm {
  def main(args: Array[String]): Unit = {
    println("Hello world")
  }
}

Related Query

More Query from same tag