zepp26
zepp26

Reputation: 11

How to declare main class for Scala in IntelliJ IDEA?

I'm trying to implement the simplest bits of coding in IntelliJ IDEA 2016.2.1 with Scala plugin, scala-sbt 0.13 and jdk-1.8. Here's the code:

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

It compiles with an error

Error: Could not find or load main class HelloWorld

In Run/Debug configurations the're is a warning 'Class HelloWorld not found in module ...'

Could you bring some light on that?

Upvotes: 1

Views: 1174

Answers (1)

notionquest
notionquest

Reputation: 39156

Right click the Scala project in IntelliJ IDE and click "Open Module Settings". Now, click "Global Libraries" and see whether Scala libraries are present there. If there is no Scala libraries, please add it.

Please refer the below snapshot.

enter image description here

Upvotes: 1

Related Questions