Run “Hello World” in Scala in IntelliJ IDE & Scala plugin
Follow the Below Steps to run the Hello World Program in Scala on intelliJ IDE , that has a definite advantage .
- Setting Up Java Environment : This is a pre-requisite for setting up Scala environment. If you don’t have this set up , go through the step by step link here to set up your java environment
- Next, download and install IntelliJ Community Edition
Install the Scala Plugin
- Open the Intellij with a Blank project . Click on File 🡪 Settings
- Click on Plugin and search for “Scala” and click on “Install”
Setting Up Intellij For Scala Development
- Open IntelliJ and click on “Create New Project” or File 🡪 New Project
- Here you can click on the Kind of project like we are going to create a Scala Project . Select “Scala” on the left and select “IDEA” on the right
- Click on “Next” and enter the name as below i.e. Project Name – “Scala Hello World” and select the Scala SDK . If you are doing it for the first time the “Scala SDK” may not be present for you. So click on “Create” and it will download the scala-sdk-<latest_version> . This will take some time to download and afterwards you can use this . Now click on “Finish”
Writing your First Scala Code in IntelliJ
- After you click on Finish , Right Click on your “src” inside “Scala-Hello-World” and click on “New” 🡪 “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.
- Name the Class to “InstrovateHello” and change the type to “Object”
- Change the code in the class to the following
object InstrovateHello extends App{
println(“This is Hello to the world from info@instrovate.com”)
}
- In order to Run your Code , Right Click on the Class and select “Run InstrovateHello”
- You would be able to see the results in the Event Log after the Compilation & Build Succeeds
So this completes the tutorial on how to run your first Hello world Program in Scala from IntelliJ IDE . There are many advantage of running the SCALA code from production deployment perspective that we would be able to notice in our upcoming session and blog.
If you want to learn how to set up IntelliJ for a scala project along with the Build tool you can visit this link –> https://docs.scala-lang.org/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.html
If you have any questions related to this you can send an email at info@instrovate.com . For Corporate Training Whatsapp / Call at +91 74289 52788