Updated with Scala 3 🥕🥕🥕
Create A Scala Application
To begin with, we need a simple Scala application. At the bare minimum, we need three files:
- build.sbt
- project/build.properties
- src/main/scala/HelloWorld.scala
Let’s go over some details about these files.
HelloWorld.scala is our main application which simply prints “Hello, World!” on the console.
@main def hello: Unit =
println("Hello world!")
build.sbt, as the name implies, defines some build-related information. We specify the name of the project, version number, and Scala version here.
name := "HelloWorld"
version := "1.0"
scalaVersion := "3.0.1"
Finally, the project/build.properties file defines the sbt version.
sbt.version = 1.5.5
When we talk about sbt versions, there are two possibilities. One is for building the project itself, which is what is defined in the build.properties file above.
There is a second sbt version that we’ll cover later, which is the sbt installed on the machine. We often refer to that as sbt-launcher and it is used to download and run a particular sbt version for building the project.