Hello World - Not working


I am new to scala and was trying to write hello world program using scala sbt.
But i am getting issue and not able to run my program. This is only happening if I am using sbt structure.
I can run program in IDEA.
Please suggest.

Does SBT work from a terminal?

1 Like

Thanks for replying.
I tried terminal also. I am getting no main class detected.

Do you have a main class?

Probably best to post the full code and your full terminal interaction showing your present working dir, what you typed and errors you received.

The error in the image hints at a binary incompatibility between scala versions.

What is using what, or how to fix it, I can’t tell you, unfortunately: I’m not an IDEA user myself.

For beginners I recommend GUI. IDEA from JetBrains is for free.

@bentito There is no code, I am just starting a new project sbt-scala. I have attached screenshot

Ah, up above,
Martijn Hoekstra

, says the correct problem.

So if you follow along to get a hello world app working from command line, here: https://docs.scala-lang.org/getting-started-sbt-track/getting-started-with-scala-and-sbt-on-the-command-line.html

Once the above works, in IntelliJ File>New>Project From Existing Sources, and choose your build.sbt file. IntelliJwill, if you stick with defaults for the dialog that comes up, create a project.

But I got the same error as you about Main class not found until I changed the Project SDK back to 1.8, I had it on Java 9. You set that under the Run Configuration dialog.

Good luck, post more screen shots if you get stuck on that path, it’s a bit tricky for first few times.


If there is no code, then it is to be expected that no main class is found. You need to write one.

@bentito Now it ran after some hiccups. I followed your steps and i can see it running. Thank You.
But i did not got why it is not running when i am creating project directly through IDEA.

If it’s working with regular sbt but not with IntelliJ, seems like that’s a bug report that should go to IntelliJ :slight_smile:

Well even creating project fully inside of IntelliJ you still do have to match the Java SDK with the Scala version and most likely you chose Java 9 when 8 was the correct choice.