Setup Scala on IntelliJ IDEA

Scala is a JVM based functional programming language widely being used in data analytics. You can install Scala on Ubuntu using sudo apt install scala. However, IDE support is inevitable these days. Therefore, this article explains how to use Scala in IntelliJ IDEA. If you want to install Scala from binary files, follow the Install Scala the Old School Way article.

Setup Scala on IntelliJ IDEA

Step 1:
Install Oracle JDK 1.8. Please note that Scala strictly requires Java 1.8. You can follow my article Install Oracle JDK 8 on Linux to install JDK 1.8 on Linux.

Step 2:
Install the latest IntelliJ IDEA. You can install either the community version or the Ultimate version depending on the license. Again, I have an article explaining how to Install IntelliJ IDEA on Linux.

Step 3:
Start IntelliJ IDEA and go to Configure → Plugins from the welcome screen or go to File → Settings → Plugins from a project screen.

Setup Scala on IntelliJ IDEA
Plugins Dialog opened from the welcome screen

Setup Scala on IntelliJ IDEA
Plugins Dialog opened in the Settings window

Step 4:
Search for the plugin named "Scala" and install it.

Step 5:
After the installation, IntelliJ will ask you to restart the IDE. Click on Restart IDE.

Setup Scala on IntelliJ IDEA

Step 6:
Create a new project and select Scala on the left side pane. On the right side, select sbt because it makes managing dependencies easier.

Setup Scala on IntelliJ IDEA

Step 7:
In the next dialog, enter the project name: ScalaHelloWorld, and make sure that you have JDK 1.8 selected and you have the latest sbt and Scala versions selected in the dropdown lists.

Setup Scala on IntelliJ IDEA

Step 8:
Click Finish and give some time to IntelliJ IDEA to download necessary files and to set up the project.

Step 9:
Now expand the project folder, right-click on scala and select New → Scala Class.

Setup Scala on IntelliJ IDEA

Step 10:
In the appeared dialog, enter the name: "HelloWorld" and select the Kind:  "Object".

Setup Scala on IntelliJ IDEA

Step 11:
Modify the content of HelloWorld.scala as given below. This code creates an object which is a subtype of App object with a println statement.
object HelloWorld extends App {
    println("Hello World!")

Step 12:
Save all the changes and run the script. You should get an output "Hello World!" as shown in the given screenshot.

Setup Scala on IntelliJ IDEA

Congratulations! You have successfully setup the Scala development environment on IntelliJ IDEA. If you encounter any issues, feel free to comment them below. I will try my best to help you.
Next Post »

Contact Form


Email *

Message *