Installing Apache Spark and Scala (Windows)

Updated: Nov 9, 2019

Main menu: Spark Scala Tutorial

In this Spark Scala tutorial you will learn how to download and install,

  • Apache Spark (on Windows)

  • Java Development Kit (JDK)

  • Eclipse Scala IDE

By the end of this tutorial you will be able to run Apache Spark with Scala on Windows machine, and Eclispe Scala IDE.


JDK Download and Installation

1. First download JDK (Java Development Kit) from this link. If you have already installed Java on your machine please proceed to Spark download and installation.

I have already installed Java SE 8u171/ 8u172 (Windows x64) on my machine. Java SE 8u171 means Java Standard Edition 8 Update 171. This version keeps on changing so just download the latest version available at the time of download and follow these steps.

2. Accept the license agreement and choose the OS type. In my case it is Windows 64 bit platform.

3. Double click on downloaded executable file (jdk*.exe; ~200 MB) to start the installation.

Note down the destination path where JDK is installing and then complete the installation process (for instance in this case it says Install to: C:\Program Files\Java\jdk1.8.0_171\).


Apache Spark Download & Installation

1. Download a pre-built version of Apache Spark from this link. Again, don't worry about the version, it might be different for you. Choose latest Spark release from drop down menu and package type as pre-built for Apache Hadoop.

2. If necessary, download and install WinRAR so that you can extract the .tgz file that you just downloaded.

3. Create a separate directory spark in C drive. Now extract Spark files using WinRAR, and copy its contents from downloads folder => C:\spark.

​Please note you should end up with directory structure like C:\spark\bin, C:\spark\conf, etc as shown above.


Configuring windows environment for Apache Spark

4. Make sure you "Hide file extension properties" in your file explorer (view tab) is unchecked. Now go to C:\spark\conf folder and rename file to

You should see filename as and not just log4j.

5. Now open with word pad and change the statement log4j.rootCategory=INFO, console --> log4j.rootCategory=ERROR, console.

Save the file and exit, we did this change to capture ERROR messages only when we run Apache Spark, instead of capturing all INFO.

6. Now create C:\winutils\bin directory.

Download winutils.exe from GitHub and extract all the files. You will find multiple versions of Hadoop inside it, you just need to focus on Hadoop version which you selected while downloading package type pre-built Hadoop 2.x/3.x in Step 1.

Copy all the underlying files (all .dll, .exe etc) from Hadoop version folder and move it into C:\winutils\bin folder. This step is needed to make windows fool as we are running Hadoop. This location (C:\winutils\bin) will act as Hadoop home.

7. Now right-click your Windows menu, Select Control Panel --> System and Security --> System --> “Advanced System Settings” --> then click “Environment Variables” button.

Click on "New" button in User variables and add 3 variables:

  1. SPARK_HOME c:\spark

  2. JAVA_HOME (path you noted while JDK Installation Step 3, for example C:\Program Files\Java\jdk1.8.0_171)

  3. HADOOP_HOME c:\winutils

8. Add the following 2 paths to your PATH user variable. Select "PATH" user variable and edit, if not present create new.

  1. %SPARK_HOME%\bin

  2. %JAVA_HOME%\bin


Download and Install Scala IDE

1. Now install the latest Scala IDE from here. I have installed Scala-SDK-4.7 on my machine. Download the zipped file and extract it. That's it.

2. Under Scala-SDK folder you will find eclipse folder, extract it to c:\eclipse.

Run eclipse.exe and it will open the IDE (we will use this later).

Now test it out!

  1. Open up a Windows command prompt in administrator mode. Right click on command prompt in search menu and run as admin.

  2. Type java -version and hit Enter to check if Java is properly installed. If you see the Java version that means Java is installed properly.

  3. Type cd c:\spark and hit Enter. Then type dir and hit Enter to get a directory listing.

  4. Look for any text file, like or CHANGES.txt.

  5. Type spark-shell and hit Enter.

  6. At this point you should have a scala> prompt as shown below. If not, double check the steps above, check the environment variables and after making change close the command prompt and retry again.

  7. Type val rdd = sc.textFile(“”) and hit Enter. Now type rdd.count() and hit Enter.

  8. You should get a count of the number of lines from readme file! Congratulations, you just ran your first Spark program! We just created a rdd with readme text file and ran count action on it. Don't worry we will be going through this in detail in next sections.

  9. Hit control-D to exit the spark shell, and close the console window.

  10. You’ve got everything set up! Hooray!

Note for Python lovers - To install pySpark continue to this blog.

Thats all!

Guys if it's not running, don't worry. Please mention in comments section below and I will help you out with installation process. Thank you.

Next: Just enough Scala for Spark

Navigation menu

1. Apache Spark and Scala Installation

1.1 Spark installation on Windows​

1.2 Spark installation on Mac

2. Getting Familiar with Scala IDE

2.1 Hello World with Scala IDE​

3. Spark data structure basics

3.1 Spark RDD Transformations and Actions example

4. Spark Shell

4.1 Starting Spark shell with SparkContext example​

5. Reading data files in Spark

5.1 SparkContext Parallelize and read textFile method

5.2 Loading JSON file using Spark Scala

5.3 Loading TEXT file using Spark Scala

5.4 How to convert RDD to dataframe?

6. Writing data files in Spark

​6.1 How to write single CSV file in Spark

7. Spark streaming

7.1 Word count example Scala

7.2 Analyzing Twitter texts

8. Sample Big Data Architecture with Apache Spark

9. What's Artificial Intelligence, Machine Learning, Deep Learning, Predictive Analytics, Data Science?

10. Spark Interview Questions and Answers