Create scala sbt project using IntelliJ IDEA – Step by step

In the previous post, we discussed how to set up a maven-based Scala project. Now, in this post, we will learn how we can create an sbt-based Scala project using IntelliJ IDEA IDE. The sbt is an open-source build tool for Scala and Java projects like Maven and Ant. If you need to install IntelliJ IDEA and set it up for Scala development, you can read this post.

These are the steps that need to be followed to create a Scala sbt project using IntelliJ IDEA:

  1. Download and install IntelliJ IDEA CE – (Covered in this post)
  2. Install Scala language plugin – (Covered in the previous post)
  3. Create a new sbt project – (Will be discussed in this post)
  4. Build and Run the sbt project – (Discussed in this post)

1. Donwload and install IntelliJ IDEA CE

We have already discussed this in detail in the previous post.

2. Install Scala language plugin

We have already discussed this in detail in the previous post.

3. Create a new sbt project

We have discussed points 1 and 2 in the previous post. Here, we will discuss how we can set up an sbt based Scala project. First, we need to open the IntelliJ IDEA application and select Projects in the left pane. Then, click on the “New Project” button located in the right pane.

Create new sbt project
Create a new sbt project

Next, a new project dialog box appears. We need to choose “Scala” in the left pane and “sbt” in the right pane and then we need to click on the “Next” button.

Select Scala sbt project type
Select Scala sbt project type

On the next screen, we need to define the project name, project location, Java SDK, sbt version, scala version, and package prefix (if needed) values. Once, all these values are provided, we can click on the Finish button at the bottom. This screen looks like this.

Configure sbt scala project
Configure sbt scala project

This will create a new sbt based scala project. The overall structure of the project looks like this.

sbt scala project
sbt scala project

Now, we can add a scala object/class file to the project and start building it. In order to add an App.scala object, right-click on the scala folder and choose New -> Scala Class.

Add App.scala object
Add App.scala object

It will ask for the scala object name and type. Provide a name for the object and select Object as type.

Configure App.scala object
Configure App.scala object

Finally, we need to add some source code to the App.scala file. We can open it by double-clicking on this file in the File Explorer and then we can add the below sample code in it.

package com.sqlrelease.application

object App {
  def main(args: Array[String]): Unit = {
    println("Hello world!")
  }
}

4. Build and Run the sbt project

Now, we can click on the Build menu and choose the Build Project option in order to build this sbt-based scala project.

Build App.scala project
Build App.scala project

Similarly, to run the App.scala file, we can click on the Run menu and select the Run App option. This will print the “Hello world!” in the output.

Thanks for the reading. Please share your inputs in the comment section.

Rate This
[Total: 1 Average: 5]

Leave a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.