ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

1、问题现象

在IDEA中编写完相关代码后运行报错:

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path

java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries.

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

2、原因

出现这个问题的原因,并不是程序的错误,而是用到了hadoop相关的服务,而windows本地又无法获取到hadoop的相关配置

3、解决

1) http://archive.apache.org/dist/hadoop/core/hadoop-2.7.0/  下载Hadoop安装包到本地并解压

比如 E:\software\hadoop-2.7.0

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

2) https://github.com/srccodes/hadoop-common-2.2.0-bin 下载该安装包到本地并解压

比如 E:\software\hadoop-common-2.2.0-bin-master

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

3) 将 E:\software\hadoop-common-2.2.0-bin-master\bin 下的所有文件copy到 E:\software\hadoop-2.7.0 下

4) 配置环境变量

4.1 添加HADOOP_HOME

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

4.2 添加CLASSPATH

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

4.3 修改Path

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

4.4 在IDEA中配置Run Configuration,添加HADOOP_HOME变量

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

4.5 再次运行代码,不再报错:

ERROR Shell: Failed to locate the winutils binary in the hadoop binary path java.io.IOException:

问题解决。