Sunday 9 August 2020

Scala Hello World in Intellij IDEA

 Step 1: Open IntelliJ IDEA.

Step 2: Intellij IDEA -> Preferences…


Step 3: Select Plugins. Search for scala plugin.


Select Scala plugin and click on Install button. Intellij will start downloading the plugin. Once the plugin is downloaded successfully, Intellij install Scala plugin.

 

Once the Scala pluing is installaed successfully, you will be asked to restart Intellij IDEA.


Click on ‘Restart IDE’ button to restart IDE.

 

Step 4: Once IDE is restarted, you will see below kind of window.



Click on ‘Create New Project’.

Click on Scala menu and select Lightbend Project Starter.

Click on Next button.


Give the project name as ‘helloworld’ and select the seed project as ‘Hello, Scala!’.

 

Click on Finish button.

 

Project structure created like below.


Open Hello.scala file, you will see below snippet.

 

Hello.scala

package example

object Hello extends Greeting with App {
  println(greeting)
}

trait Greeting {
  lazy val greeting: String = "hello"
}

Run the application Hello.


You will see the message hello in the console.

 

That’s it you are done……:)




Previous                                                    Next                                                    Home

No comments:

Post a Comment