score:21

Accepted answer

Probably you imported project somehow wrong. I see scala folder is not highlighted as sources. Usually, you don't even need to setup Run configuration manually for Scala SBT project. Do you have Scala and SBT Plugins in your IDE?

You should open SBT projects through "Import project" and choose "build.sbt" file. I would also recommend enabling auto-import to install all of the dependicies.

That's how it look for me: Here how it looks for me

If you still wanna make it manually your configuration should work. That's my Run configuration that works:

My run configuration

score:-1

I met the same issue, please check the whole execute command and check the configuration, make sure the compiled files path is correctly configured. refer to my screenshot:
refer to my screenshot

score:0

Had a similar problem with latest Intellij IDEA build (2022.1.1) and scala 3.1.2 - both sbt and Intellij scala projects. For me the solution was to use non-ascii path.

score:1

Create a new project and make sure SBT is proper loaded along with Scala Library. This happens with many times, bad internet connection or failure of Scala library/SBT loading might be some of the reasons. Best of Luck for Next Project, Happy Developers & Coders.

score:2

Hi I solved this problem by defining the class in src package under main and by setting up the configuration as default.enter image description here

score:3

In my case the object in the object MyObject extends App was nested, if you have it unested meaning in your scala file it's not under any other object it made it work.

Netsted caused this error in intellij:

object External {
  object MyMain extends App // Could not find or load main class in scala in intellij IDE

}

While the below unested worked:

object External { }
object MyMain extends App // Worked!

score:5

To fix this issue in my project I invalidated caches and restarted:

enter image description here

score:7

You will get this error if you tried to open the project and imported it incorrectly. I would open the project like this in Intellij:

File>New> Project from Existing Source>(select) Import project from external model>
(select)sbt

click Next>Finish

score:40

My problem was resolved when I marked src folder as sourced root. Click with the right button in src folder -> Mark Directory as -> Sources root


Related Query

More Query from same tag