Wednesday, 26 August 2020

How to build jar file and run the jar using SBT?

// Sample program
package my1st

object my1st {
  def main(args:Array[String]) : Unit = {
    println("Hello World")
  }
}


SBT - Scala Build Tool (Simple Build Tool) / Simple Build Tool

Download and install sbt from here : https://www.scala-sbt.org/download.html



Open the project in IntelliJ Idea
Right click the project name - Copy - Copy Path
Select : Absolute Path : C:\Users\sankara\IdeaProjects\my1st
Open Windows Explorer
Do paste in address bar
Shift + Right click on the free space 
Open command prompt here


C:\Users\sankara\IdeaProjects\my1st>dir
 Volume in drive C has no label.
 Volume Serial Number is 363F-334D

 Directory of C:\Users\sankara\IdeaProjects\my1st

26-08-2020  12:44    <DIR>          .
26-08-2020  12:44    <DIR>          ..
26-08-2020  13:21    <DIR>          .idea
26-08-2020  12:42               328 build.sbt
26-08-2020  12:43    <DIR>          project
26-08-2020  12:40    <DIR>          src
26-08-2020  12:44    <DIR>          target
               1 File(s)            328 bytes
               6 Dir(s)  334,877,937,664 bytes free

sbt package --> to build jar file

C:\Users\sankara\IdeaProjects\my1st>sbt package
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; sup
port was removed in 8.0
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_202)
[info] loading project definition from C:\Users\sankara\IdeaProjects\my1st\project
[info] loading settings for project my1st from build.sbt ...
[info] set current project to my1st (in build file:/C:/Users/sankara/IdeaProjects/my1st/)
[success] Total time: 2 s, completed 26 Aug, 2020 1:31:33 PM

sbt run --> to run the jar 

C:\Users\sankara\IdeaProjects\my1st>sbt run
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] welcome to sbt 1.3.13 (Oracle Corporation Java 1.8.0_202)
[info] loading project definition from C:\Users\sankara\IdeaProjects\my1st\project
[info] loading settings for project my1st from build.sbt ...
[info] set current project to my1st (in build file:/C:/Users/sankara/IdeaProjects/my1st/)
[info] running my1st.my1st
Hello World
[success] Total time: 3 s, completed 26 Aug, 2020 1:32:34 PM

Flume - Simple Demo

// create a folder in hdfs : $ hdfs dfs -mkdir /user/flumeExa // Create a shell script which generates : Hadoop in real world <n>...