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