Running an App Subclass

Using Scala plugin 0.6.334 on Leda 123.4 (Linux), when I create a new project via File > New Project > Other/Scala Module and create a class Main extends App { println("Hello, world!") } I cannot run the project. That is, right-clicking on Main.java displays following related items:

  • Make Module 'ScalaHelloWorld'
  • Compile 'Main.scala'
  • Run Scala Console
  • Send Selection To Scala Console (inactive)
  • Run Scala Worksheet


In Run > Edit Configurations, I create a new Defaults/Application instance and try to set Main class: to my Main.scala, but this time IDEA complains that Main is not acceptable. Instead of extending App, if I create an object Main { def main(args: Array[String]) { println("Hello, world!") } }, I can assign it as Main class: in Edit Configurations window.

What might I be missing? Isn't App subclasses supported at this moment?

0
2 comments

In Scala it's not possible to run classes, but you can run objects.

object Main extends App {
  println("Hello, world!")
}



Best regards,
Alexander Podkhalyuzin.

0

Oops! I really felt like a dumb. Thanks for the clarification though.

0

Please sign in to leave a comment.