Home > Software design >  Unable to run a standlone scala file
Unable to run a standlone scala file

Time:11-12

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

CodePudding user response:

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.

CodePudding user response:

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

  • Related