GuruKulki
GuruKulki

Reputation: 26418

What is the cause of an UnsatisfiedLinkError?

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

Upvotes: 15

Views: 60025

Answers (4)

bnhede
bnhede

Reputation: 31

I had a similar issue with a native DLL

Caused by: java.lang.ExceptionInInitializerError: java.lang.UnsatisfiedLinkError: ....org.eclipse.osgi\1092\0\.cp\natives\com\sap\jvm\inspector\ntamd64\sapjvm_inspector.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2040)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1934)
at java.lang.Runtime.loadLibrary0(Runtime.java:871)
at java.lang.System.loadLibrary(System.java:1134)
at com.sap.jvm.inspector.WithInspectorNativeLib.loadWithAppropriateMechanism(WithInspectorNativeLib.java:205)
at com.sap.jvm.inspector.WithInspectorNativeLib.lambda$static$1(WithInspectorNativeLib.java:58)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.jvm.inspector.WithInspectorNativeLib.<clinit>(WithInspectorNativeLib.java:57)
at com.sap.jvm.inspector.board.BoardManager.createForLocal(BoardManager.java:70)
at com.sap.jvm.profiling.ui.widgets.vmexplorer.BoardsController.<init>(BoardsController.java:54)
at com.sap.jvm.profiling.ui.widgets.vmexplorer.BoardsController.<clinit>(BoardsController.java:40)
at com.sap.jvm.profiling.ui.workbench.views.vmexplorer.VmExplorerInput.<init>(VmExplorerInput.java:40)
at com.sap.jvm.profiling.ui.workbench.views.configuration.AbstractProfilingConfigurationView.openNode(AbstractProfilingConfigurationView.java:2624)
at com.sap.jvm.profiling.ui.workbench.views.configuration.AbstractProfilingConfigurationView.handleEvent(AbstractProfilingConfigurationView.java:2653)

Turns out the MSVCR120 dll was missing.And I fixed this using the install of the 2013 version of the microsoft distributables that were missing in default installation of win11. https://www.microsoft.com/en-us/download/details.aspx?id=40784

I found the missing lib using the tool at this link https://github.com/lucasg/Dependencies . You have to load the dll file with the tool and it shows the missing dependencies as errors. the below image shows the fixed dependency after installing the MSVCRT tools.

https://i.sstatic.net/j8qGy.png

Upvotes: 1

phantom-99w
phantom-99w

Reputation: 983

To quote 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...

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

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...

Upvotes: 2

Mark
Mark

Reputation: 29119

From the Javadoc:

Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared 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.

-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

Upvotes: 25

extraneon
extraneon

Reputation: 23950

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

On windows, this would be 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.

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

Upvotes: 3

Related Questions