Running the Book Code
Install the Example Code
Download the zipped code repository. To find the zipped version, press the green "Code" button. Unpack the archive.
Install IntelliJ IDEA
We use IntelliJ IDEA to develop the examples in this book. You may use another environment such as VSCode but if you do you'll need to figure it out yourself.
-
Follow the instructions here to install IntelliJ IDEA.
-
Start IntelliJ IDEA, and choose 'Open' to open an existing project. Navigate to where you unzipped the repository.
-
If the Scala plugin isn't installed, IDEA will prompt you. Accept the prompt to install the plugin.
-
When you open any of the chapter files in
src/main/scala
, as you scroll down you will see green arrows on the left of each runnable example. When you press an arrow, that example will run in a console and show you the output. -
You might need to restart JetBrains IDEA after configuring. Also check for running tasks in the IDE; you might need to wait the first time you open the project before the green arrows appear.
Configuring the Scala SDK
When you open a Scala file in IntelliJ, you might get a message in the title bar of that file:
No Scala SDK in module
On the right side of that message bar, you'll see:
Setup Scala SDK
Click on this. In the resulting dialog box, select "Create" and choose the latest Coursier version of Scala, which will be version 3.x. The Dialog box will now look something like this:
Select "OK". Now go to File | Project Structure | Global Libraries
and Choose Scala 3, like this: