(FA23) Getting Scala to run locally
Prerequisites: access to a terminal.
- Install Scala 3 using this link
- Install VSCode using this link
- Open VSCode, find the “Extensions” page (Code -> Preferences -> Extension) , and install the “Metals” extension on VScode.
- Create a new file, hello.worksheet.sc, and type in
println ("Hello world!")
on line 1. Save and wait a bit, you should see// Hello world
to the right of that line. You can now run Scala code locally! - (Optional - Importing existing Scala projects) Clone this project using the command
git clone https://github.com/scala/scala3-example-project.git
. You may need to installgit
. Open the newly cloned directory on VSCode, import the build withMetals: Import Build
command, and runMain.scala
.
Browser alternative with no installation
Use the online code editor at https://scastie.scala-lang.org/ - you will need to sign up for GitHub. You can save and share snippets, but will not be able to import other people’s projects.
More details
The getting started page on the Scala website has more detailed instructions about creating a new project and using Scala from the command line.