This presentation will guide you on how to install the sbt tool to work on the scala command interpreter. This also have the some basic information and important links where you can find the study material.
2. Agenda
• Software Requirements
• Installing the jdk and jre
• Installing Scala Interpreter
• Working with Scala interpreter
• Important links
3. System & Software Requirement
• Windows : PreferredWindows 10
• RAM : 8GB or more
4. Installing jdk and jre
• Go to Oracle website and find for Java
SE Development Kit 8u191 or visit
link: Java SE Development Kit 8
Downloads.
• Select relevant machine and click on
respective download link.
Note: click on radio button to accept the
License Agreement.
• Install the jdk executable file and note
the location while installing the jdk and
complete the instalation.
• To cross check the installation of jdk
simply go to the CMD and execute
javac command. If it says javac is not
recognized then the java is not
installed on your system.
5. • You can also cross check by going to
the windows explorer, 99% times java
will be installed in the C folder in
Program Files folder.
• If java folder exist that mean java is
already installed.
• After installing you need to set the
environment variable for the java in
this system,To do that follow the
below steps:
1. Go toControl Panel
2. Click on System and Security
3. Click on System
4. Click on Advance System Settings
and on EnvironmentVariables
6. 5. Go to SystemVariable and select PATH and
click on edit
6. Click on New,You need to copy the folder
path until bin for the jdk folder in windows
explorer which you have installed in
system(program files folder) in my case it is
as shown in the below fig.
7. Similarly for the jre also, Note down the jre
path until bin and paste it in the path under
environment variable by clicking on new
button add it in the path.
8. Now we will set JAVA_HOME User variable
under UserVariable at the top.
7. 9. Click on new and write JAVA_HOME in
variable and input theVariable value as
path of java which you installed,This time
you need to copy the path until jdk folder
only as shown in the fig.
10. Now check for javac in Command Prompt
and it will compile java source file and
successfully installed the java in the
system.
8. Installing Scala Interpreter
• Now we will install sbt i,.e. Scala Interpreter.
• To download search for Scala download or visit
page: Scala download
• Download and Install sbt MSI file for windows.
• Note down the path in which the sbt is
installed.
• Browse for the installed location i.e. Program
Files(X86) search for the sbt folder and copy
the path until bin folder and set the
environment variable for the same by
following same steps which we followed for jdk
and jre.
9. Working with Scala interpreter
• Go toCommand Prompt and create project by mkdir or you can
directlyCD to the folder.
• Create folder with the command mkdir Scala Samples and click on
enter.This folder you will see in Users folder in C drive named as Scala
Samples. Or you can directly give path in which you want to create
project with CD command.
Ex: C:Usersankit> mkdir Scala Samples (create new folder)
OR C:Usersankit> cd C:UsersankitScala Samples (existing folder)
• Enter sbt command and for the very first time it will take some time
to download some necessary files and directories related to the Scala
projects.
10. • Now start the Scala Interpreter by entering command as sbt console
and it will take you to the Scala Interpreter and you can start using it
for the coding.
11. Working with Scala interpreter
• Scala is modern multi-paradigm programming language designed to
express common programming patterns in a concise, elegant and
type-safe way.
• Scala is scalable language and it use uses most of Object Oriented
concepts.
• Before Scala language Java, Ruby, R and Python were known
languages for the Spark Operations.
• Dynamic in nature.
• IDE Support(NetBeans, IntelliJ, Eclipse).
• Uses Java existing libraries.
12. • We can use Scala for comparing strings example shown below:
scala> val a = "Ankit“ // within double quote it will treat as string
a: String = Ankit
scala> val b = "ankit"
b: String = ankit
scala> a == b // compare a string with b string
res0: Boolean = false
scala> a.toUpperCase == b.toUpperCase // comparing two string a and b. By
converting both the strings to upper case and comparing
res1: Boolean = true
13. Input: scala> "I work for company SAP LABS".split(" ").foreach(println) //printing each word
will be printing in next line
Output:
I
work
for
company
SAP
LABS
-------------------------
Input: val s = "I work for company, SAP LABS&FreeLancer"
s: String = I work for company, SAP LABS&FreeLancer
scala> s.split(“ ").map(_.trim)// splitting the string by space and trimming it will convert it to the
array of string.
Output: res4: Array[String] = Array(I, work, for, company,, SAP, LABS&FreeLancer)