O'Reilly logo

Pragmatic Scala by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scala on the Command Line

The scala command can run in two modes, as an interactive shell or in batch mode. If we don’t provide any arguments, as we saw, the command brings up the interactive shell. However, if we provide a filename then it runs the code in it within a stand-alone JVM.

The file we provide may be a script file or an object file—that is, a compiler-generated .class file. By default, we can let the tool guess the type of the given files. Alternately, use the -howtorun option to tell it to treat the file as a script file or as an object file. Finally, to send Java properties, use the -Dproperty=value format. Let’s create a file and run it using the command.

Here’s a file named HelloWorld.scala with the following contents:

FirstStep/HelloWorld.scala ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required