Writing your first Scala Project in Windows

I love to explore different languages (computer languages to be specific) and in my journey to do so, Scala is a milestone. But, whoosh! installing it and running it successfully on my machine was definitely a task. I am not talking about the Scala REPL but setting up an interactive build tool for Scala like SBT.


We will be using coursier to prepare the environment. There are two options for this, either you can download the windows installer from here, or you can open the command prompt and type the following command,

>bitsadmin /transfer cs-cli https://git.io/coursier-cli-windows-exe “%cd%cs.exe”

This will install all the standard Scala applications.

This is the coursier windows installer
Coursier Windows Installer
Typing in the command in the Command Prompt also does the job.


Next is setting up the IDE. You can use IntelliJ and install the Scala plugins but I will be using VS Code and the Powershell to execute my files.

Since I will be just using PowerShell to execute the files, there is no need to set up VS Code for running the programs. However, if you are going to use IntelliJ I recommend you to read how to install IntelliJ and the Scala plugin.


Next, you have to install Java Development Environment. I recommend you download the installer from Adopt Open JDK.


Next, do not forget to add the java development kit to your environment variables. For this, go to,

Edit Environment Variable -> Path -> New -> "Add the path to jdk folder"
Click onPath


Now is the time to install the sbt. Download the Windows installer from here. In case you want to use any third-party installation package like Chocolatey, you can see it in the documentation.


Having installed everything now is the time to check if everything is working fine and is installed. So, open your PowerShell and check if java, scala, and sbt all are installed properly in your system. For this run the following commands one after the other,

> java --version
> scala --version
> sdt --version


Once it's ensured that everything is up, installed, and working properly, now is the time we get into making our very first project.

For the sake of the same, I have created a folder Scala in D Drive and will be making my project in it. You can make it anywhere you want to. Now once inside the Scala folder, I am creating a folder HelloWorld to create my first project. The command would be,

> mkdir HelloWorld
> cd HelloWorld


Now, inside the HelloWorld folder start the sbt-shell. This will also install any required files for the project.

> sbt

Select c (for continue) when the command prompts to and you will end up in the sbt-shell.


Now, You have to create two files. One is build.sbt which will be inside the HelloWorld directory. This is our build file. Next is HelloWorld.scala which will be inside HelloWorld/src/scala/example folder. This is the file where we are going to write our first program. The directory listing will be something like this,


Once that’s done it’s time to create our first progam. In the HelloWorld.scala file write the following lines of code,


Finally, we are done with the steps. Now save your file and come back to PowerShell. In the sbt-shell we opened, type,

> compile
> run

And, there is the output!

That’s it! I have taken references from the SBT Reference Manual to write my first Scala program.




Coding Enthusiast | Bibliophile | Zoophilist

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Asynchronous Programming In Java

8 Easy UI Hacks for Developers Who Care

Transitioning To A Software Developer: The Andela Boot-camp Journey

Go Defer Simplified with Practical Visuals

Orchestration based Saga Pattern for microservices with Camunda

The main buzz words from KubeCon 2021 — My personal takeaways from the conference

Can we go from Doing Agile to Being Agile?

Amazon CodeGuru: Automate Code Quality with Machine Learning | Rolustech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rushali Sarkar

Rushali Sarkar

Coding Enthusiast | Bibliophile | Zoophilist

More from Medium

How to apply commands on STATA using the IF condition?

Use deep learning model as preprocessing step

Five tricks you should know about Azure Machine Learning Service

What happens when you type ls -l *.c and hit Enter in a Shell?