VaidAbhishek
VaidAbhishek

Reputation: 6144

Unable to run a standlone scala file

I'm following examples out of Programming in Scala book by Odersky and I'm unable to run a simple standalone scala file with scala hello.scala. When I do this, I get this error:

Error: Could not find or load main class hello.scala
Caused by: java.lang.ClassNotFoundException: hello.scala

I'm using scala3.

Here's a state of my file and commands I'm running.

enter image description here

Upvotes: 0

Views: 40

Answers (2)

mtk
mtk

Reputation: 168

you might consider using the new (and excellent) tool from virtuslab called 'scala-cli': https://scala-cli.virtuslab.org/

Upvotes: 0

Jarrod Baker
Jarrod Baker

Reputation: 1220

If you follow the steps from the documentation you'll see that you need to compile your file before running it.

If you run:

scalac hello.scala
scala hello

You should get the result you want.

Upvotes: 2

Related Questions