在windows中的intellij中运行wordcount程序,控制台输出以下报错

wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access-LMLPHP

在Intellij编辑器中解决办法:本地重新创建NativeIO类,修改一个方法返回值,然后用新建的NativeIO类覆盖源码中的NativeIO类。下面会展示。首先按2次shift,找到NativeIO,然后选择 download resource下载源码

wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access-LMLPHP

然后在项目的java目录下重建一个NativeIO类,用于覆盖该源码,ctrl+A选中NativeIO源码,覆盖掉在java目录下新建的NativeIO类

wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access-LMLPHP

在NativeIO类中找到access0返回值所在的方法,将返回参数改成return true。

wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access-LMLPHP

至此,再次运行wordcount程序,报错问题得以解决

wordcount在本地运行报错解决:Exception in thread "main" java.lang.UnsatisfiedLinkError:org.apache.hadoop.io.native.NativeID$Windows.access-LMLPHP

04-16 09:37