java 在资源路径中找不到 JNA 原生支持 (/com/sun/jna/linux-arm/libjnidispatch.so)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14635999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 16:54:57  来源:igfitidea点击:

JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

javajnaraspberry-pi

提问by P?r Fransman

I have started to build a java service which incorporates JNA to load a native C/C++ lib and i want to run the java service on the Raspberry PI aka arm platform. I have successfully built a stable ground of the service and it runs on both Windows7 and linux-amd64/debian but.. on the RPI platform i get the above stated error: Exception in thread "main" java.lang.UnsatisfiedLinkError: JNA native support (/com/sun/jna/linux-arm/libjnidispatch.so) not found in resource path

我已经开始构建一个 Java 服务,它结合了 JNA 来加载本地 C/C++ 库,我想在 Raspberry PI aka arm 平台上运行 Java 服务。我已经成功地建立了一个稳定的服务基础,它可以在 Windows7 和 linux-amd64/debian 上运行,但是..在 RPI 平台上我得到了上述错误:线程“main”中的异常 java.lang.UnsatisfiedLinkError: JNA native在资源路径中找不到支持 (/com/sun/jna/linux-arm/libjnidispatch.so)

On the RPI i have done the following: * Installed both openjdk7 and java8 beta with arm hard float support. * Installed libjna-java lib.

在 RPI 上,我完成了以下操作: * 安装了 openjdk7 和 java8 beta 并支持 arm 硬浮动。* 安装了 libjna-java 库。

Following are set:

设置如下:

Java

爪哇

root@pisces:/opt/TellstickReplay# java -version
java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b36e)
Java HotSpot(TM) Client VM (build 25.0-b04, mixed mode)
root@pisces:/opt/TellstickReplay#

LD_LIBRARY_PATH

LD_LIBRARY_PATH

root@pisces:/opt/TellstickReplay# echo $LD_LIBRARY_PATH
/opt/lib/jna

CLASSPATH

类路径

root@pisces:/opt/TellstickReplay# echo $CLASSPATH
/usr/lib/jna

None of the settings seems to satisfy JAVA with JNA support. I have even tried to export both jna.jar and linux-arm.jar into the project in Eclipse and all together rebuild the jars into the exported jar still getting the same error. The exported jar has been tested successfully on both windows and linux so the jar file is working.

这些设置似乎都不能满足具有 JNA 支持的 JAVA。我什至尝试将 jna.jar 和 linux-arm.jar 都导出到 Eclipse 中的项目中,并且一起将 jar 重新构建到导出的 jar 中,但仍然出现相同的错误。导出的 jar 已在 windows 和 linux 上成功测试,因此 jar 文件正在运行。

I have also tried to just use CLASSPATH in the Manifest in the jar file but with no success. I have also tried to explicitly load the libjnidispatch.so from the absolute path but JAVA then starts to complain that it cannot find the file to libjnidispatch.so even that the path is 100% correct.

我也尝试在 jar 文件的 Manifest 中使用 CLASSPATH 但没有成功。我还尝试从绝对路径显式加载 libjnidispatch.so,但是 JAVA 开始抱怨它找不到 libjnidispatch.so 的文件,即使路径是 100% 正确的。

So.. does anyone know HOW to correctly get JNA support on the Raspberry PI platform to work?? Please, im getting tremendously frustrated and soon giving up hope to fix this..

那么.. 有谁知道如何在 Raspberry PI 平台上正确获得 JNA 支持?拜托,我感到非常沮丧,很快就放弃了解决这个问题的希望。

回答by stkim1

I am re-compiling Apache Sparkfor RPI2 and I've spent a couple of days to fix the issue. Then I've found the easiest possible solution. All you need to have is a libjnidispatch.so link in your default JVM's native lib path.

我正在为 RPI2重新编译Apache Spark,我花了几天时间来解决这个问题。然后我找到了最简单的解决方案。您所需要的只是默认 JVM 的本机库路径中的 libjnidispatch.so 链接。

sudo -s ln -s /usr/lib/arm-linux-gnueabihf/jni/libjnidispatch.so /usr/lib/jvm/default-java/jre/lib/arm/libjnidispatch.so

回答by technomage

Where is libjnidispatch.so on your system? If it's not on your system, JNA will attempt to unpack it from jna.jar from the indicated resource path. If it's not there either, you'll get the UnsatisfiedLinkError.

您系统上的 libjnidispatch.so 在哪里?如果它不在您的系统上,JNA 将尝试从指定资源路径的 jna.jar 中解压它。如果它也不存在,您将获得UnsatisfiedLinkError.

It's recommended that you explicitly install libjnidispatch.so on your system where possible; the jna.jar bundling is mostly there to facilitate usage on the more common desktop platforms.

建议您尽可能在系统上显式安装 libjnidispatch.so;jna.jar 捆绑主要是为了方便在更常见的桌面平台上使用。

linux-arm.jarcontains the most recent build of libjnidispatch.so, but only WebStart knows how to automatically load the native from a jar like that. If you unpack it into /opt/lib/jna (or elsewhere on LD_LIBRARY_PATH), you should avoid the link error.

linux-arm.jar包含 libjnidispatch.so 的最新版本,但只有 WebStart 知道如何从这样的 jar 中自动加载本机。如果将其解压到 /opt/lib/jna(或 LD_LIBRARY_PATH 上的其他位置),则应避免链接错误。

回答by Eivind

I packaged the new jna.jar (4.0) and it includes the linux-arm/libjnidispatch.so. The code I was trying to run now works.

我打包了新的 jna.jar (4.0),它包含了 linux-arm/libjnidispatch.so。我试图运行的代码现在可以工作了。

回答by nicephotog

I'd say its more of "glitch of configuration of the location for the "libjnidispatch.so" in the OS your using or that particular JRE systems internal folder/package/JNDI-structure, it may not be an identically laid out Debian or Java JRE.

我想说的更多是您使用的操作系统或特定 JRE 系统内部文件夹/包/JNDI 结构中“libjnidispatch.so”位置的“配置故障”,它可能不是布局相同的 Debian 或爪哇JRE。