linux to build scala environment and write a simple scala program
- 2021-01-06 00:52:46
- OfStack
Installing the scala environment under linux is simple, and if it is ubuntu, it is even simpler and straightforward
apt-get
java/scala systems need to be based on jdk, so the first thing to do is to install jdk.
1. Installing jdk is a cliche. It's not worth mentioning.
2. Install scala as follows:
sudo apt-get install scala
As follows:
ubuntu@VM-0-15-ubuntu:~/taoge/scala$ scala -version
Scala code runner version 2.11.6 -- Copyright 2002-2013, LAMP/EPFL
ubuntu@VM-0-15-ubuntu:~/taoge/scala$
Of course, you can also use shell to enter scala, as follows:
ubuntu@VM-0-15-ubuntu:~/taoge/scala$ scala
Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_151).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
OK, let's write an scala program test:
ubuntu@VM-0-15-ubuntu:~/taoge/scala$ cat test.scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
ubuntu@VM-0-15-ubuntu:~/taoge/scala$ scala test.scala
Hello, world!
ubuntu@VM-0-15-ubuntu:~/taoge/scala$
spark is written in scala, so some knowledge of scala is necessary.
conclusion