The simplest way to run Spark on Windows is via Windows Subsystem for Linux (WSL 2) with Docker Desktop. With this approach you do not need Hadoop or winutils at all:
- Install WSL 2 (run
wsl --installin PowerShell as admin) - Install Docker Desktop for Windows with the WSL 2 backend enabled
- Open your WSL terminal, clone this repo, and run
docker compose up --scale spark-worker=3 - Open the project in IntelliJ (it can use the WSL JDK or a Windows JDK 17+)
If you prefer a native Windows setup without WSL, follow the steps below.
Apache Spark doesn't have its own distributed file system, so it relies on Hadoop libraries for file I/O
even in local mode on Windows. You need winutils.exe and hadoop.dll for Spark to work correctly.
- Java Development Kit (JDK) 17 or 21 (Spark 4.x does NOT support Java 8 or 11)
- The
winutils.exebinary for Hadoop 3.4.x
Download and install Eclipse Temurin JDK 21 (recommended) or Oracle JDK 21.
During installation, check the option to set JAVA_HOME automatically, or do it manually in Step 3.
The required winutils.exe and hadoop.dll (Hadoop 3.4.0) are included in this repository under windows/.
- Create the folder
C:\hadoop\bin - Copy
windows\winutils.exeandwindows\hadoop.dllfrom this repo intoC:\hadoop\bin
- Open the Start menu and search for "Environment Variables"
- Click "Edit the system environment variables"
- Click the "Environment Variables" button
- Under "System Variables":
- Click "New" and add:
- Variable name:
JAVA_HOME - Variable value: the path to your JDK installation (e.g.,
C:\Program Files\Eclipse Adoptium\jdk-21.0.6.7-hotspot)
- Variable name:
- Click "New" again and add:
- Variable name:
HADOOP_HOME - Variable value:
C:\hadoop
- Variable name:
- Click "New" and add:
- Find the "Path" variable in the System Variables list and click "Edit"
- Add these two entries:
%JAVA_HOME%\bin%HADOOP_HOME%\bin
- Click "OK" to close all windows
Open a new Command Prompt or PowerShell window and run:
java -version
winutils.exe chmod 777 /tmp/hive
If both commands succeed without errors, you're ready to run Spark.
The steps above are sufficient for Spark to run in local mode for this course. You do not need to install or configure a full Hadoop distribution (HDFS, YARN, etc.).
Troubleshooting:
java.io.IOException: Could not locate executable winutils.exe—HADOOP_HOMEis not set correctly orwinutils.exeis not in%HADOOP_HOME%\binUnsatisfiedLinkError: hadoop.dll— make surehadoop.dllis also in%HADOOP_HOME%\binand%HADOOP_HOME%\binis on your PATHUnsupportedClassVersionError— you are running an older JDK (8 or 11). Spark 4.x requires JDK 17 or 21.