Official website: https://www.scala-lang.org/
key to see Scala has the following characteristics:
- Object-Oriented Programming
- Functional Programming
- A high-level language
- Based on JVM
- key easily call Java class
utility class Java class common-lang3 - Learning Scala for later learning is helpful Spark, Flink, Kfk etc.
- key complementary with other languages, but that is not necessarily the key instead of other languages
Scala version currently roughly follows these:
- 2.9
- 2.10
- 2.11 √
- 2.12
- 2.13
Quguan download the following network perspective, this latest version has the 2.13.0 version.
This study now will be able to choose 2.11, behind Spark with this version.
Environmental requirements: to ensure that Java 8 JDK
Now choose the 2.11 version, find All previous releases of the previous version
and then find SCALA 2.11.8, other 2.11 version is also available.
Now go download the scala-2.11.8.tgz this fall Linux.
Windows can download this scala-2.11.8.msi, fool installation.
Download after decompression:
[hadoop@hadoop001 soft]$ tar -zxvf scala-2.11.8.tgz -C ~/app/
And configuration environment variable to take effect:
[hadoop@hadoop001 scala-2.11.8]$ vi ~/.bash_profile
export SCALA_HOME=/home/hadoop/app/scala-2.11.8
export PATH=$SCALA_HOME/bin:$PATH
[hadoop@hadoop001 scala-2.11.8]$ source ~/.bash_profile
In fact, you can use more than one version, which put the notes with which can be removed, such as spark:
Start Scala, enter the interactive command line, enter the console:
[hadoop@hadoop001 scala-2.11.8]$ scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_45).
Type in expressions for evaluation. Or try :help.
scala> 1+1
res0: Int = 2
scala> res0*3
res1: Int = 6
scala> res0*res1
res2: Int = 12
scala> println("how are you?")
how are you?
Scala code development time, certainly not on the console, develop, validate the console, or can exercise their own, or to develop based on IDEA.
But did not bring scala IDEA default, you need to manually install scala plugin that is not
how IDEA install scala? Two ways ①②
① one is the online installation, this little plug, but the network is better, or may fail to install.
In the Plugins in direct search scala, first installation is not, so to click 3
can be installed.
② The second way is installed, the above is the Scala plugin package, downloaded to the local computer, and then click Install from local disk to the figure below.
Create a new maven project:
then completed.
Automatically jumped out, point it to the point which can
wait a bit to build success:
You can then put App, AppTest, MySpec to delete, build their own back.
Open the pom.xml file,
then, Scala dependence:
pom.xml file, many if not needed can be deleted.
If the code is not regular, you can format the code, appears to look good:
then change it to this place, modified to version 8, the default is 5 version.
The following packets establish
the following code in which:
package com.ruozedata.bigdata.scala01
object HelloApp {
def main(args: Array[String]): Unit = {
println("Welcome to China ")
}
}
Running about, OK.
Note: The first time you install Scala, and Scala project to establish the first time, will download the dependencies will be downloaded to the local repository source, very long time. Other Java, etc. too.