Java UnsatisfiedLinkError 的原因是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2446426/
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-08-13 07:47:15  来源:igfitidea点击:

What is the cause of an UnsatisfiedLinkError?

java

提问by GuruKulki

When i am trying to run my program it is giving the following error

当我尝试运行我的程序时出现以下错误

       Exception in thread "main" java.lang.UnsatisfiedLinkError: no jacob-1.14.3-x86 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at com.jacob.com.LibraryLoader.loadJacobLibrary(LibraryLoader.java:184)
at com.jacob.com.JacobObject.<clinit>(JacobObject.java:108)
at javaSMSTest.main(javaSMSTest.java:18)

please help

请帮忙

采纳答案by Mark

From the Javadoc:

来自 Javadoc:

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.

如果 Java 虚拟机找不到声明为 native 的方法的合适的本地语言定义,则抛出。

It is an error related to JNI. loadJacobLibrary is trying to load the native library called jacob-1.14.3-x86 and it is not found on the path defined by java.library.path. This path should be defined as a system property when you start the JVM. e.g.

这是一个与 JNI 相关的错误。loadJacobLibrary 正在尝试加载名为 jacob-1.14.3-x86 的本机库,但在 java.library.path 定义的路径上找不到它。启动 JVM 时,应将此路径定义为系统属性。例如

-Djava.library.path=<dir where jacob library is>

On Windows, the actual native library file will be called jacob-1.14.3-x86.dll while on Linux it would be called libjacob-1.14.3-x86.so

在 Windows 上,实际的本机库文件将被称为 jacob-1.14.3-x86.dll 而在 Linux 上它将被称为 libjacob-1.14.3-x86.so

回答by extraneon

You need the jacob-1.14.3-x86 library on your java library path.

您的 java 库路径上需要 jacob-1.14.3-x86 库。

On windows, this would be jacob-1.14.3-x86.dll.

在 Windows 上,这将是 jacob-1.14.3-x86.dll。

This is a binary file which is used by java to run native methods. It's probably required by some library (jar) you're using.

这是一个二进制文件,java 使用它来运行本机方法。您正在使用的某些库(jar)可能需要它。

In hereyou can see not only a jar, but also the binary required by the jar. Pick the one for your platform.

这里,您不仅可以看到 jar,还可以看到 jar 所需的二进制文件。为您的平台选择一个。

回答by phantom-99w

To quote http://www.velocityreviews.com/forums/t143642-jni-unsatisfied-link-error-but-the-method-name-is-correct.html:

引用http://www.velocityreviews.com/forums/t143642-jni-unsatisfied-link-error-but-the-method-name-is-correct.html

There are two things that cause UnsatisfiedLinkError. One is when System.loadLibrary() fails to load the library, the other is when the JVM fails to find a specific method in the library. The text of the error message itself will indicate which is the case...

有两件事会导致 UnsatisfiedLinkError。一种是 System.loadLibrary() 无法加载库,另一种是 JVM 无法在库中找到特定方法。错误消息本身的文本将表明是哪种情况......

The error which you describe clearly cannot find the library at all. As the others have said, include it in your Java library path.

您清楚地描述的错误根本找不到库。正如其他人所说,将它包含在您的 Java 库路径中。

The other error—when the library can be found but the method within the library is not found—looks as follows:

另一个错误 - 当可以找到库但找不到库中的方法时 - 如下所示:

java.lang.UnsatisfiedLinkError: myObject.method([Ljava/lang/Object;)V

In this case you either have the wrong method name, or will have to go back and add the method and recompile the code...

在这种情况下,您要么使用了错误的方法名称,要么必须返回并添加该方法并重新编译代码...