Scala Collections – Environment Setup

Scala Collections - Environment Setup

This topic is about Scala Collections – Environment Setup.

Scala can be installed on any UNIX flavored or Windows based system. Before you start installing Scala on your machine, you must have Java 1.8 or greater installed on your computer.

Follow the steps given below to install Scala.

Step 1: Verify Your Java Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the following two commands depending on the platform you are working on.

If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

PlatformCommandSample Output
WindowsOpen Command Console and type βˆ’\>java -versionJava version “1.8.0_31″Java (TM) SE Run TimeEnvironment (build 1.8.0_31-b31)Java Hotspot (TM) 64-bit ServerVM (build 25.31-b07, mixed mode)
LinuxOpen Command terminal and type βˆ’$java -versionJava version “1.8.0_31″Open JDK Runtime Environment (rhel-2.8.10.4.el6_4-x86_64)Open JDK 64-Bit Server VM (build 25.31-b07, mixed mode)

We assume that the readers of this tutorial have Java SDK version 1.8.0_31 installed on their system.

In case you do not have Java SDK, download its current version from https://www.oracle.com/technetwork/java/javase/downloads/index.html and install it.

Step 2: Set Your Java Environment

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,

Sr.NoPlatform & Description
1WindowsSet JAVA_HOME to C:\ProgramFiles\java\jdk1.8.0_31
2LinuxExport JAVA_HOME=/usr/local/java-current

Append the full path of Java compiler location to the System Path.

Sr.NoPlatform & Description
1WindowsAppend the String “C:\Program Files\Java\jdk1.8.0_31\bin” to the end of the system variable PATH.
2LinuxExport PATH=$PATH:$JAVA_HOME/bin/

Execute the command java -version from the command prompt as explained above.

Step 3: Install Scala

You can download Scala from www.scala-lang.org/downloads. At the time of writing this tutorial, I downloaded ‘scala-2.13.1-installer.jar’. Make sure you have admin privilege to proceed. Now, execute the following command at the command prompt βˆ’

PlatformCommand & OutputDescription
Windows\>java -jar scala-2.13.1-installer.jar\>This command will display an installation wizard, which will guide you to install Scala on your windows machine. During installation, it will ask for license agreement, simply accept it and further it will ask a path where Scala will be installed. I selected default given path “C:\Program Files\Scala”, you can select a suitable path as per your convenience.
LinuxCommand βˆ’$java -jar scala-2.13.1-installer.jarOutput βˆ’Welcome to the installation of Scala 2.13.1!The homepage is at βˆ’ http://Scala-lang.org/press 1 to continue, 2 to quit, 3 to redisplay1…………………………………………[ Starting to unpack ][ Processing package: Software Package Installation (1/1) ][ Unpacking finished ][ Console installation done ]During installation, it will ask for license agreement, to accept it type 1 and it will ask a path where Scala will be installed. I entered /usr/local/share, you can select a suitable path as per your convenience.

Finally, open a new command prompt and type Scala -version and press Enter. You should see the following βˆ’

PlatformCommandOutput
Windows\>scala -versionScala code runner version 2.13.1 — Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.
Linux$scala -versionScala code runner version 2.13.1 — Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.tut

In this topic, we learned about Scala Collections – Environment Setup. To know more, Click Here.

Leave a Reply