java.lang.UnsatisfiedLinkError no *****.dll in java.library.path
In order for System.loadLibrary()
to work, the library (on Windows, a DLL) must be in a directory somewhere on your PATH
or on a path listed in the java.library.path
system property (so you can launch Java like java -Djava.library.path=/path/to/dir
).
Additionally, for loadLibrary()
, you specify the base name of the library, without the .dll
at the end. So, for /path/to/something.dll
, you would just use System.loadLibrary("something")
.
You also need to look at the exact UnsatisfiedLinkError
that you are getting. If it says something like:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no foo in java.library.path
then it can't find the foo library (foo.dll) in your PATH
or java.library.path
. If it says something like:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.example.program.ClassName.foo()V
then something is wrong with the library itself in the sense that Java is not able to map a native Java function in your application to its actual native counterpart.
To start with, I would put some logging around your System.loadLibrary()
call to see if that executes properly. If it throws an exception or is not in a code path that is actually executed, then you will always get the latter type of UnsatisfiedLinkError
explained above.
As a sidenote, most people put their loadLibrary()
calls into a static initializer block in the class with the native methods, to ensure that it is always executed exactly once:
class Foo {
static {
System.loadLibrary('foo');
}
public Foo() {
}
}
java.lang.UnsatisfiedLinkError: no frmjapi in java.library.path
The reason is that obviously your library behind the scene relies on a native library at runtime, so you need to add the root directory of the file frmjapi.dll
to java.library.path
as suggested in your error message by adding -Djava.library.path=c:\some\path\to\my\dll\parent\dir
in your VM arguments (cf. Run Configuration).
What is
frmjapi.dll
?
frmjapi.dll
is a file from Oracle Corporation which is part of Oracle
Developer.frmjapi.dll
is located indoracledev10g\bin\frmjapi.dll
.
Why am I getting this UnsatisfiedLinkError with native code?
@mmyers Thank you for responding. We found out that all we had to do was change System.loadLibrary to System.load and pass the full path + filename as argument, worked like a charm.
Even before doing so, we tried using the "-D" parameter and setting LD_LIBRARY_PATH but we weren't successful.
Go figure! :)
Thanks again,
Karen
java.lang.UnsatisfiedLinkError: no opencv_java2411 in java.library.path
-Djava.library.path
shouldn't point to the DLL, but to the folder containing the DLL. e.g. -Djava.library.path=D:/Projects/lib/opencv/x86/
java.lang.UnsatisfiedLinkError even on setting -Djava.library.path
System.loadLibrary expects library name, not a path. The path to the directory containg the library should be set in PATH (Windows) env variable or in -Djava.library.path
Java unsatisfied link error no HelloWorld in java.library.path
This should happen because when you run your Java program, it cannot find the HelloWorld
shared library (.dll
, .so
... depending on your OS).
Try this to check where the JVM expects you to put the shared library, and place it in one of the directories you see:
System.out.println(System.getProperty("java.library.path"));
Generally, the working directory is a safe choice.
Related Topics
Convert Latitude/Longitude Point to a Pixels (X,Y) on Mercator Projection
What Is the Java's Internal Represention for String? Modified Utf-8? Utf-16
Difference Between @Before, @Beforeclass, @Beforeeach and @Beforeall
Java Thread.Sleep Puts Swing UI to Sleep Too
Is It Wrong to Use Deprecated Methods or Classes in Java
How to Execute System Commands (Linux/Bsd) Using Java
Why Doesn't Java Support Unsigned Ints
Method for Evaluating Math Expressions in Java
Javafx Tableview Text Alignment
Only Using @JSONignore During Serialization, But Not Deserialization
How to Run .Jar File by Double Click on Windows 7 64-Bit
Differencebetween Integer and Int in Java
Synchronizing on String Objects in Java
How Can a String Be Initialized Using " "
Selenium Webdriver How to Resolve Stale Element Reference Exception