Search code examples
windowsscalaread-eval-print-loop

Load a Scala File From Command Line


I'm fairly new to Scala and I'm having troubles running a .scala file from command line. I've tried the following commands

1.\PathToDirContaingingCode> scala myCode.scala

2.\PathToDirContaingingCode> scala
   scala> :load myCode.scala

3.\PathToDirContaingingCode> scala
   scala> :load \PathToDirContaingingCode\myCode.scala

All of these result in "That file does not exist"

I know that the code is correct because I've run it in the REPL already.


Solution

  • I've finally found my answer.

    \PathToDirContainingCode> scala
    scala> :lo myCode.scala
    

    The proper Scala command I was looking for was :lo