Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java native library System.loadLibrary fails with UnsatisfiedLinkError

Tags:

java

c++

native

I'm trying to use a native C++ library in Java.

When I'm loading it with

System.loadLibrary(filename);

I get the error:

java.lang.UnsatisfiedLinkError: Directory separator should not appear in library name: C:\HelloWorld.dll

Any ideas how I can solve this?

like image 891
Stefan Avatar asked Apr 08 '26 19:04

Stefan


2 Answers

Just use:

System.loadLibrary("HelloWorld"); // without c:\ and without ".dll" extension

Also, make sure HelloWorld.dll is available on your library path.

like image 92
Pablo Santa Cruz Avatar answered Apr 10 '26 10:04

Pablo Santa Cruz


loadLibrary needs the filename without the path and the extension.

If you wanna use the full path, you can try the System.load() method.

See java.lang.System API.

like image 21
Ralph Löwe Avatar answered Apr 10 '26 09:04

Ralph Löwe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!