Exercise 09 - Setup scala, sbt and integrate with eclipse

sbt
eclipse
scala
#1

Problem:

Link for reference - http://www.itversity.com/lessons/apache-spark-with-scala/

  • Setup Scala
  • Setup sbt
  • Add plugin sbteclipse
  • Install Scala IDE
  • Create sbt project

Please provide output of Hello World program from Scala IDE and sbt project:

  • Copy of build.sbt
  • Output from Scala IDE

Here are the steps

  • Launch scala
  • Write Hello World program
  • Sample code

object hw {

  def main(args: Array[String]) {
    println("Hello World!")
  }
}
0 Likes

#2

#Launch scala

C:\Users\farhan.misarwala>scala
Welcome to Scala 2.12.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.

scala>

#Write Hello World program

scala> object HelloWorld {
     |  def main(args: Array[String]): Unit = {
     | println("Hello world" + args(0))
     |  }
     | }
defined object HelloWorld

scala> HelloWorld.main(Array(" by Farhan"))
Hello world by Farhan

#Copy of build.sbt

name := "Scala GUI"
 
version := "1.0"
 
scalaVersion := "2.11.7"

libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "1.0.1"

#Output from Scala IDE

Hello world by Farhan

0 Likes

#3

scala>

========================================================

name := "hw"
version := "1.0"
scalaVersion := “2.12.1”

========================================================
HelloWorld

0 Likes

#4

name := "hw"
version := "1.0"
scalaVersion := “2.11.8”

========================================================
Hello World!

0 Likes

#5

name := "hw"
version := "1.0"
scalaVersion := “2.11.8”

object hw {
def main(args: Array[String]) {
println(“Hello World!”)
}
}

Hello World!

0 Likes

#6

build.sbt ::

name := "hw"
version := "1.0"
scalaVersion := “2.12.1”

Output of SCALA IDE::

Hello World!

0 Likes

#7

name := "hw"
version := "1.0"
scalaVersion := “2.11.8”

object hw {
def main(args: Array[String]) {
println(“Hello World!”)
}
}

0 Likes

#8

build.sbt

name := "HelloScala"
version := "1.0"
scalaVersion := “2.11.8”

Sample code

object HelloScala {
def main(args:Array[String]){
println(“Hello Scala…!!!”)
}
}

0 Likes