IntelliJ IDEA



In this tutorial, we’ll see how to build a minimal Scala project using IntelliJIDE with the Scala plugin. In this guide, IntelliJ will download Scala for you.

  1. Idea Community Edition
  2. Intellij Idea Java
  3. Intellij Idea Themes
  4. Idea Ide

Installation

  1. Make sure you have the Java 8 JDK (also known as 1.8)
    • Run javac -version on the command line and make sure you see javac 1.8.___
    • If you don’t have version 1.8 or higher, install the JDK
  2. Next, download and install IntelliJ Community Edition
  3. Then, after starting up IntelliJ, you can download and install the Scala plugin by following the instructions onhow to install IntelliJ plugins (search for “Scala” in the plugins menu.)

When we create the project, we’ll install the latest version of Scala.Note: If you want to open an existing Scala project, you can click Openwhen you start IntelliJ.

Intellij idea 2020

Location of the IDE files depends on the operating system, product and version. 2020.1 and above versions 2019.3.x and below versions Examples for IntelliJ IDEA 2020.3: Windows: Configuration (i. Starting from IntelliJ IDEA 2016 and the most recent versions of the lightweight IDEs, we are bundling custom JRE (JetBrains Runtime) with Linux distributions, just like we've been doing for Mac. Our custom JRE is based on OpenJDK and includes the most up to date fixes to provide better user experience on Linux (like font rendering improvements.

Creating the Project

  1. Open up IntelliJ and click File => New => Project
  2. On the left panel, select Scala. On the right panel, select IDEA.
  3. Name the project HelloWorld
  4. Assuming this is your first time creating a Scala project with IntelliJ,you’ll need to install a Scala SDK. To the right of the Scala SDK field,click the Create button.
  5. Select the highest version number (e.g. 2.13.5) and click Download. This mighttake a few minutes but subsequent projects can use the same SDK.
  6. Once the SDK is created and you’re back to the “New Project” window click Finish.

Writing code

IdeaIntellij

Idea Community Edition

  1. On the Project pane on the left, right-click src and selectNew => Scala class. If you don’t see Scala class, right-click on HelloWorld and click on Add Framework Support…, select Scala and proceed. If you see Error: library is not specified, you can either click download button, or select the library path manually. If you only see Scala Worksheet try expanding the src folder and its main subfolder, and right-click on the scala folder.
  2. Name the class Hello and change the Kind to object.
  3. Change the code in the class to the following:

Running it

  • Right click on Hello in your code and select Run ‘Hello’.
  • You’re done!

Intellij Idea Java

Experimenting with Scala

Ultimate

A good way to try out code samples is with Scala Worksheets

  1. In the project pane on the left, right clicksrc and select New => Scala Worksheet.
  2. Name your new Scala worksheet “Mathematician”.
  3. Enter the following code into the worksheet:
IntelliJ IDEA

As you change your code, you’ll notice that it gets evaluatedin the right pane. If you do not see a right pane, right click on your Scala worksheet in the Project pane, and click on Evaluate Worksheet.

Next Steps

Now you know how to create a simple Scala project which can be usedfor starting to learn the language. In the next tutorial, we’ll introducean important build tool called sbt which can be used for simple projectsand production apps.

Intellij Idea Themes

Up Next: Building a Scala Project with IntelliJ and sbt

Idea Ide

Contributors to this page: