Let’s see how to Install Scala Plugin in IntelliJ IDEA IDE tool and run the Spark Hello world example in Scala, IntelliJ IDE provides developers with editing and debugging support
8.1k
By Nick Cotes
Let’s see how to Install Scala Plugin in IntelliJ IDEA IDE tool and run the Spark Hello world example in Scala, IntelliJ IDE provides developers with editing and debugging support for Scala applications. IntelliJ IDEA is the most used IDE for Scala due to its early adaptation and good scala code competition.
IntelliJ IDE by default doesn’t come with a Scala plugin hence you need to install explicitly from settings.
If you already have IntelliJ IDE setup and wanted to just install the Scala plugin jump to the next section. In case if you wanted to install IntelliJ, follow the below steps.
IntelliJ IDEA comes with mainly two editions; community & ultimate. To run the scala application we will use the community edition, so download IntelliJ IDEA community edition.
You can either download windows installer(.exe) or as a compressed zip (.zip) file based on your convenience. I’ve downloaded the .zip file.
2. Now, let’s unzip either using Winzip, 7-Zip, or any other zip extracts you have. I’ve used 7-Zip to extract the contents to the folder.
3. Move the extracted folder from Downloads to your working folder. In my case, I am moving it to c:apps.
4. Start IntelliJ IDE by running idea64.exe from C:appsideaIC-2020.2.1.winbinidea64.exe
2. Install Scala Plugin in IntelliJ
Start IntelliJ IDE by running idea64.exe from installation folder. I have installed IntelliJ at C:appsideaIC-2020.2.1.winbinidea64.exe and follow the below steps to install the Scala plugin.
Steps to install Scala Plugin in IntelliJ
Open File > Settings (or using shot keys Ctrl + Alt + s )
Select the Plugins option from the left panel. This brings you Feature panel.
Click on Install to install the Scala plugin.
4. After scala plugin installation completes, restart the IntelliJ IDE.
3. Create a Scala Project using scala-archetypes-simple In IntelliJ
Follow the below steps to create a Scala project using Scala archetype in IntelliJ (org.scala-tools.archetypes:scala-archetypes-simple)
The archetype is a kind of templates that creates the right directory structure and downloads the required default dependencies. Since we have selected Scala archetypes, it downloads all Scala dependencies and enables IntelliJ to write Scala code.
5. In the next window, enter the project name. I am naming my project as scala-hello-world-example.
6. On next screen, review the options for artifact-id and group-id
7. Select Finish.
You will see the project created on IntelliJ and shows the project structure on left Project panel.
4. Setup Scala SDK
Now install Scala SDK, if you already have downloaded Scala you can point it to the local filesystem or you can download the Scala libraries from the IntelliJ itself.
IntelliJ will prompt you as shown below to Setup Scala SDK.
2. Select Setup Scala SDK, it prompts you the below window,
3. Select the create option.
4. From the next window select the Download option and
5. Choose the Scala version 2.12.12 (latest at the time of writing this article)
6. Make changes to pom.xml file
Now, we need to make some changes in the pom.xml file, you can either follow the below instructions or download the pom.xml file GitHub project and replace into your pom.xml file.
First, change the Scala version to the latest version, I am using 2.12.12