0

I just created a simple helloworld scala project in Intellij. My main class is simply printing Hello World -

package xx.yy.zz

object HelloWorld{

  def main(args: Array[String]): Unit = {
    System.out.print("Hello World!")
  }

}

My project structure

scala-test
|_src
  |_main
    |_scala
      |_xx
        |_yy
          |_zz
            |_HelloWorld 

In the project structure settings, I have "scala" as my source folder. I am able to select my main class correctly in the application run configuration I created. So far so good. After this, when I try to run my run configuration, I get the dreaded error -

Error: Could not find or load main class xx.yy.zz.HelloWorld

At this point, I have tried all the things I could find on google like invalidating cache, reloading project, switching source folder to be "src" instead of "scala" and many others that I have lost track of by now. Please help!!

NITS
  • 207
  • 4
  • 15
  • 2
    Please see https://stackoverflow.com/a/42660624/104891. Does it help? If the issue persists, please share the [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and the logs (Help | Collect Logs and Diagnostic Data). – CrazyCoder Aug 19 '20 at 17:02
  • Thanks @CrazyCoder. I had already reviewed this post. It sure helped me in initial stages. My problem turned out to be in the gradle file. I had listed my repo and dependencies under "subprojects" instead of "allprojects". Fixing this fixed my issues. – NITS Sep 01 '20 at 13:38

1 Answers1

0

I didn't investigate the reasons for this issue but as a workaround, you can compile the project via sbt/shell sbt before running via Intellij.

Oleg Zinoviev
  • 549
  • 3
  • 14