As part of this topic, we will explore another way of compiling and running the jar file with arguments through SBT
- We can make the changes to the code
- Recompile the jar file
- Run the jar file
- How to pass the arguments to the program
Example
import scala.io.Source object OrderRevenue { def main(args: Array[String]) = { val orderId = args(1).toInt val orderItems = Source.fromFile("/home/dgadiraju/data/retail_db/order_items/part-00000").getLines val orderRevenue = orderItems.filter(oi => oi.split(",")(1).toInt == orderId). map(oi => oi.split(",")(4).toFloat). reduce((t, v) => t + v) println(orderRevenue) } }
Run the program using this below command
scala target/scala-2.10/retail_2.10-1.0.jar OrderRevenue 2