Scala环境搭建
一、官网
https://www.scala-lang.org/download/all.html
二、下载
1、首先,确保安装了Java 8 JDK
[hadoop@hadoop002 ~]$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
2、地址
https://www.scala-lang.org/download/2.11.8.html
三、解压
tar -xzvf scala-2.11.8.tgz -C ~/app
四、配置环境变量并生效
vi ~/.bash_profile
export SCALA_HOME=/home/hadoop/app/scala-2.11.8
export PATH=$SCALA_HOME/bin:$PATH
source ~/.bash_profile
五、启动scala
[hadoop@hadoop002 ~]$ 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>
六、脚本编译
[hadoop@hadoop001 tmp]$ vi HelloScala.scala
object HelloScala {
def main(args: Array[String]) {
println("Hello Scala")
}
}
编译:[hadoop@hadoop001 tmp]$ scalac HelloScala.scala
编译玩生成HelloScala.class
[hadoop@hadoop001 tmp]$ ls
HelloScala.class HelloScala$.class HelloScala.scala
运行:[hadoop@hadoop001 tmp]$ scala HelloScala
Hello Scala