环境
- 操作系统:Centos 6.5 X64
- IP地址:192.168.56.100
- JDK 环境:
$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
接下来的操作都是使用root
用户进行操作。
下载安装
下载
下载地址:http://www.scala-lang.org/download/
下载后直接解压并配置环境变量:
$ mkdir -p /opt
$ cd /opt
$ wget http://downloads.lightbend.com/scala/2.12.1/scala-2.12.1.tgz
$ tar zxf scala-2.12.1.tgz
配置
$ cat >> /etc/profile <<EOF
>
> #add scala path to system path
> export PATH=\$PATH:/opt/scala-2.12.1/bin
> EOF
$ source /etc/profile
使用测试
交互式界面操作:
$ scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
Type in expressions for evaluation. Or try :help.
scala> println("Hello, world!")
Hello, world!
scala>
文件形式:
编辑文件HelloWorld.scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
运行程序:
$ scala HelloWorld.scala
Hello, world!