windows下ElascticSearch报错java.lang.UnsatisfiedLinkError
一、重现
今天想学一下ElasticSearch,根据教程从官网下载了最新版本的ElasticSearch,解压后打开bin文件夹双击elasticsearch.bat,发现启动报错如下。
java.lang.UnsatisfiedLinkError: Native library (com/sun/jna/win32-x86/jnidispatch.dll) not found in resource path
([file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-cli-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-core-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-geo-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-launchers-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-plugin-classloader-7.13.3.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-secure-sm-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/elasticsearch-x-content-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/HdrHistogram-2.1.9.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/hppc-0.8.1.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jackson-core-2.10.4.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jackson-dataformat-cbor-2.10.4.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jackson-dataformat-smile-2.10.4.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jackson-dataformat-yaml-2.10.4.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/java-version-checker-7.13.3.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jna-5.7.0-1.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/joda-time-2.10.10.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jopt-simple-5.0.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/jts-core-1.15.0.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/log4j-api-2.11.1.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/log4j-core-2.11.1.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-analyzers-common-8.8.2.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-backward-codecs-8.8.2.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-core-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-grouping-8.8.2.jar,
file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-highlighter-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-join-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-memory-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-misc-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-queries-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-queryparser-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-sandbox-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-spatial-extras-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-spatial3d-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/lucene-suggest-8.8.2.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/snakeyaml-1.26.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/spatial4j-0.7.jar, file:/E:/devTools/ElasticSearch/elasticsearch-7.13.3/lib/t-digest-3.2.jar])
二、解决方案
一句话说明白,jdk版本是32位的,而这里ElasticSearch的版本是64位的,所以会报错,解决方法是换jdk。
1.删掉该删的
右键我的电脑,高级系统设置,环境变量
2.装64位版的jdk
这里就不赘述了,贴一个官网地址自己搞去吧
jdk官网下载(没有*比较慢)
三、心路历程
windows装elasticSearch本来是学习中最简单的一步,但我一步就迈坑里了。。。
也是尝试了各种网上的方法无果,网上基本没有windows启动报这个错误的,在尝试了包括但不限于换ElasticSearch版本,更改jvm大小等方法后都没有解决,我对自己陷入了深深的怀疑。。。
后来看到这个bug是dll的问题,网上有说linux这个问题是jdk版本32和ES64位的不匹配,我猛然间想起我的jdk好像也是32位的,然后尝试了一下换jdk,问题果然解决了!
再次记录一下这个问题,希望可以帮助到和我一样问题的小伙伴(应该没有人和我一样64位的机器用32位的jdk)。