Accepted answer

here is a good explanation of your problem with the solution.

  1. download the version of winutils.exe from

  2. set up your hadoop_home environment variable on the os level or programmatically:

    system.setproperty("hadoop.home.dir", "full path to the folder with winutils");

  3. enjoy


that's a tricky one... your storage letter must be capical. for example "c:\..."


on top of mentioning your environment variable for hadoop_home in windows as c:\winutils, you also need to make sure you are the administrator of the machine. if not and adding environment variables prompts you for admin credentials (even under user variables) then these variables will be applicable once you start your command prompt as administrator.


i have also faced the similar problem with the following details java 1.8.0_121, spark spark-1.6.1-bin-hadoop2.6, windows 10 and eclipse oxygen.when i ran my in eclipse using hadoop_home as a system variable as mentioned in the previous post, it did not work, what worked for me is -

system.setproperty("hadoop.home.dir", "path/to/the/dir");

path/to/the/dir/bin=winutils.exe whether you run within eclipse as a java application or by spark-submit from cmd using

spark-submit --class groupid.artifactid.classname --master local[2] /path to the jar file created using maven /path to a demo test file /path to output directory command

example: go to the bin location of spark/home/location/bin and execute the spark-submit as mentioned,

d:\bigdata\spark-2.3.0-bin-hadoop2.7\bin>spark-submit --class com.bigdata.abdus.sparkdemo.wordcount --master local[1] d:\bigdata\spark-quickstart\target\spark-quickstart-0.0.1-snapshot.jar d:\bigdata\spark-quickstart\wordcount.txt


setting the hadoop_home environment variable in system properties didn't work for me. but this did:

  • set the hadoop_home in the eclipse run configurations environment tab.
  • follow the 'windows environment setup' from here


  • download winutils.exe and hadoop.dll in your windows machine.
  • create folder c:\hadoop\bin
  • copy winutils.exe and hadoop.dll in newly created hadoop folder
  • setup environment variable hadoop_home=c:\hadoop


i got the same problem while running unit tests. i found this workaround solution:

the following workaround allows to get rid of this message:

    file workaround = new file(".");
    system.getproperties().put("hadoop.home.dir", workaround.getabsolutepath());
    new file("./bin").mkdirs();
    new file("./bin/winutils.exe").createnewfile();



if we see below issue

error shell: failed to locate the winutils binary in the hadoop binary path could not locate executable null\bin\winutils.exe in the hadoop binaries.

then do following steps

  1. download winutils.exe from win-alpha/winutils.exe.
  2. and keep this under bin folder of any folder you created for.e.g. c:\hadoop\bin
  3. and in program add following line before creating sparkcontext or sparkconf system.setproperty("hadoop.home.dir", "c:\hadoop");


you can alternatively download winutils.exe from github:

replace hadoop-2.7.1 with the version you want and place the file in d:\hadoop\bin

if you do not have access rights to the environment variable settings on your machine, simply add the below line to your code:

system.setproperty("hadoop.home.dir", "d:\\hadoop");


on windows 10 - you should add two different arguments.

(1) add the new variable and value as - hadoop_home and path (i.e. c:\hadoop) under system variables.

(2) add/append new entry to the "path" variable as "c:\hadoop\bin".

the above worked for me.


1) download winutils.exe from 
2) create a directory in windows "c:\winutils\bin
3) copy the winutils.exe inside the above bib folder .
4) set the environmental property in the code 
  system.setproperty("hadoop.home.dir", "file:///c:/winutils/");
5) create a folder "file:///c:/temp" and give 777 permissions.
6) add config property in spark session ".config("spark.sql.warehouse.dir", "file:///c:/temp")"


follow this:

  1. create a bin folder in any directory(to be used in step 3).

  2. download winutils.exe and place it in the bin directory.

  3. now add system.setproperty("hadoop.home.dir", "path/to/the/dir"); in your code.


  1. download winutils.exe
  2. create folder, say c:\winutils\bin
  3. copy winutils.exe inside c:\winutils\bin
  4. set environment variable hadoop_home to c:\winutils

Related Query

More Query from same tag