Thursday 17 September 2020

Scala: Hello World project in Eclipse

 

Prerequisite:

Install Scala IDE in Eclipse.

 

Step 1: Open Eclipse. File -> New -> Other.

 

Search for scala.

 


 

Select ‘Scala Project’ and click on Next button.

 

Give the project name as ‘hello-world-scala’.

 



Click on Finish button. Project structure looks like below.

 

 


Step 2: Create new package ‘com.sample.app’.

 

Right click on the project ‘hello-world-scala’.

 

File -> New -> Scala Package Object.




Give the package name as ‘com.sample.app’.

 

 


Click on Finish button.

 

Step 3: Define MainApp class.

 

Right click on the package ‘com.sample.app’ -> New -> Scala App.

 

 


Give the app name as com.sample.app.MainApp.

 

 


Click on Finish button.

 

MainApp generated code looks like below.

package com.sample.app

object MainApp extends App {
  
}

 

Add some  println messages to the body of MainApp class and run the application.

 

MainApp.java

 

package com.sample.app

object MainApp extends App {
  
    println("Welcome to Scala Programming!!!")
    
}

 

Step 4: Run MainApp class.

 

Right click on MainApp -> Run As -> Scala Application.

 

 

 


You will see below message in console.

 

Welcome to Scala Programming!!!

 


 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment