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

问题出现的原因是hadoop目录bin文件下缺少 winutils.exe 文件;

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

查看源码:public static final String getQualifiedBinPath(String executable) throws IOException {
String fullExeName = HADOOP_HOME_DIR + File.separator + "bin" + File.separator + executable;
File exeFile = new File(fullExeName);
if (!exeFile.exists()) {
throw new IOException("**Could not locate executable " + fullExeName + " in the Hadoop binaries."**);
} else {
return exeFile.getCanonicalPath();
}
}

前去 https://github.com/srccodes/hadoop-common-2.2.0-bin 下载 winutils.exe

解决办法一:安装hadoop并且配置环境变量

C:\\Program Files\\Hadoop\\hadoop-2.7.3\\bin
C:\\Program Files\\Hadoop\\hadoop-2.7.3\\bin\\winutils.exe

解决办法二:在你的程序中加上

System.setProperty("hadoop.home.dir", "C:\\Program Files\\Hadoop\\hadoop-2.7.3")
加上这么一句话就ok了