In this post, we will describe the procedure for Scala Installation on Ubuntu Machine.
Below are the basic requirement for Scala installation on Ubuntu and getting started.
- Java 1.5 or Later versions installed and JAVA_HOME environment variable set to Java installation directory
Scala Installation Procedure:
- Download the latest stable version of Scala from http://www.scala-lang.org/download/. Gzipped binary tar ball of scala-x.y.z.tgz format can be downloaded directly. In this post we are using, scala-2.11.7.tgz file.
- Copy the tar ball into our preferred installation directory location (preferably into /opt/scala) and extract the gzipped file.
- Set the Scala installation directory location to SCALA_HOME environment variable in .bashrc file.
Close and reopen terminal (or source .bashrc file) to take changes to the environment variables
Verify Scala Installation:
Lets verify the Scala installation on Ubuntu with $ scala -version command, which will display version details of Scala.
Example Run in Scala
We can run examples in Scala shell which is like any other CLI session, we can open scala shell with $ scala command
Hello World in Scala CLI
Scripts will be executed by $ scala <script_path> command.
Short-cuts in Scala Shell:
- Ctrl+A takes you to the beginning of the line and Ctrl+E to the end of the line.
- Up/Down keys for accessing previous commands
- Ctr+D quits the scala shell