Learn Scala Environment Setup | How to Install Scala

1. Install Scala – Objective

This article on Scala Environment Setup will guide you through setting up Scala for your system. Along with this, we will learn how to install Scala Programming. If you still haven’t begun with the language, now’s your chance.

So, let’s start “How to Install Scala”.

Learn Scala Environment Setup and Get Started with an IDE

Learn Scala Environment Setup and Get Started with an IDE (Install Scala)

2. Scala Environment Setup

We know that Scala runs on the JVM. So for Scala Environment Setup, you’ll need to have Java installed on your machine. To check, open the command prompt and type the following:

Scala Environment Setup - Install Scala

Image.1 Scala Environment Setup

This tells us that we have Java 1.8 involved. If it isn’t installed for you, you can download it here:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

3. How to Install Scala?

Now, we’ll need to Install Scala. For learning purposes, we can simply download the binaries from the official site:

https://www.scala-lang.org/download/

This is around 123.7MB heavy.

Once you hit download, you’ll see the following:

Scala Setup Environment: Install Scala

Image.2 Scala Setup Environment: Install Scala

Click Next.

Scala Setup Environment: Install Scala

Image.3 Scala Setup Environment: Install Scala

Here, make sure the checkbox for the terms and conditions is checked. Then, click Next.

 Scala Setup Environment: Install Scala

Image.4 Scala Setup Environment: Custom Setup

Now, this dialog lets you select the features you want to install.

Setup Scala Environment: Ready to Install Scala Programming

Image.5 Setup Scala Environment: Ready to Install Scala Programming

We’re ready to install it. Click on ‘Install’.

Install Scala Programming Language Distribution

Image.6 Install Scala Programming Language Distribution

Wait as it installs.

Completed the Scala Programming Language Distribution Setup Wizard

Image.7 Completed the Scala Programming Language Distribution Setup Wizard

We’re done; click ‘Finish’.

Now, when you get in the command prompt, type scala:

C:\Users\lifei>scala

Welcome to Scala 2.12.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_151).

Type in expressions for evaluation. Or try :help.

scala>

This will give you the Scala prompt. Here, you can type in expressions to evaluate:

scala> println("Hello")
Hello
scala> 2+3
res1: Int = 5

If, however, you want to run your program as a script, save it as a file with a .scala extension, and move to that location. Here’s the file we use:

object hello extends App{
    println("Hello")
}

First, let’s quit Scala in the command prompt by pressing Ctrl+C and then pressing y, and then Enter:

scala> Terminate batch job (Y/N)? y

C:\Users\lifei>

Now, let’s get to the Desktop, since that is where we saved the file:

C:\Users\lifei>cd Desktop

Then, to compile the script, run the following command:

C:\Users\lifei\Desktop>scalac hello.scala

Next, to run the script, do the following:

C:\Users\lifei\Desktop>scala hello

Hello

C:\Users\lifei\Desktop>

There you go! All set for your journey with Scala.

Scala Quiz

4. Getting Started with an IDE

To build projects with Scala, you’ll need to work with an IDE. In this tutorial, we’ll use IntelliJ IDEA. First, download it from here:

https://www.scala-lang.org/download/

Then, you’ll drive through the following screens:

Scala Environment Setup: IDEA Setup

Image.8 Scala Environment Setup: IDEA Setup

Scala Environment Setup: Choose Install Location

Image.9 Scala Environment Setup: Choose Install Scala Location

Here, you can select which folder to install Scala in.

Setup Scala Environment: Installation Options

Image.10 Setup Scala Environment: Scala Installation Options

You may choose to create a Desktop shortcut, or even create associations with Java, Groovy, and kt.

Choose Start Menu Folder

Image.11 Choose Start Menu Folder

Where do you want to create shortcuts for the program in the Start Menu? Or would you like to create a new folder?

IDEA Installing

Image.12 IDEA Installing

Let it install.

Completing IDEA Setup

Image.13 Completing IDEA Setup

Phew, we’re done. Now, click on ‘Finish’.

Import IDEA setting form

Image.14 Import IDEA setting form

A couple final formalities.

License Agreement

Image.15 License Agreement

Accept the user license agreement to continue.

Data Sharing Options

Image.16 Data Sharing Options

You can opt to anonymously send usage statistics to JetBrains, the brain of IntelliJ.

Scala Environment Setup

Image.17 Scala Environment Setup

You can either activate your license or evaluate it for free. We downloaded the Ultimate edition.

Setup Scala Environment

Image.18 Setup Scala Environment

Learn Scala Environment Setup and Get Started with an IDE

Image.19 Learn Scala Environment Setup and Get Started with an IDE

Let’s evaluate it for free.

Accept.

Set UI Theme

Image.20 Set UI Theme

Do you prefer a lighter theme or the darker, more popular Darcula?

UI Themes Default Plugin

Image.21 UI Themes Default Plugin

Choose the plugins you want.

Customize IDEA

Image.22 Customize IDEA

Download Featured Plugins

Image.23 Download Featured Plugins

You can also download featured plugins.

Download Featured Plugins

Image.24 Download Featured Plugins

Let’s download for Scala.

Download Featured Plugins

Image.25 Download Featured Plugins

Learn Scala Environment Setup and Get Started with an IDE

Image.26 IntelliJ IDEA

Learn Scala Environment Setup and Get Started with an IDE

Image.27 IntelliJ IDEA – Install

It’s installed.

We’re all done! Open it.

Create a new project.

IDEA New Project

Image.28 IDEA New Project

Choose Scala.

After this, you can choose your own configurations for your project, including the JDK.

So, this was all about Scala Environment Setup Tutorial. Hope you like our explanation.

5. Conclusion

Hence, we studied all the steps to install Scala. Hope you had fun installing Scala on your machine. Still, have a query, feel free to ask in the comment box.

Reference

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.