本文以CentOS 7
为例,介绍如何搭建Scala
开发环境:
(1)安装Scala
:
执行“yum install scala
”命令:
[root@localhost ~]# yum install scala
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirrors.tds.net
* extras: bay.uchicago.edu
* updates: dallas.tx.mirror.xygenhosting.com
Nothing to do
提示找不到Scala
安装包,所以采用另外方式。使用wget
命令直接下载:
[root@localhost ~]# wget http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.rpm
--2015-05-27 22:07:32-- http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.rpm
......
Length: 111919675 (107M) [application/octet-stream]
Saving to: ‘scala-2.11.6.rpm’
100%[=========================================================================>] 111,919,675 298KB/s in 6m 15s
2015-05-27 22:13:48 (291 KB/s) - ‘scala-2.11.6.rpm’ saved [111919675/111919675]
接下来安装Scala
:
[root@localhost ~]# rpm -ivh scala-2.11.6.rpm
Preparing... ################################# [100%]
Updating / installing...
1:scala-2.11.6-0 ################################# [100%]
安装成功,执行Scala
:
[root@localhost ~]# scala
/usr/bin/scala: line 23: java: command not found
运行Scala
需要JRE
支持,所以下一步安装Java
环境。
(2)执行yum install java
:
[root@localhost ~]# yum install java
......
Complete!
(3)运行scala
,打印“Hello world!
”:
[root@localhost ~]# scala
Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.
scala> print("Hello world!")
Hello world!
scala> :quit
安装成功!