Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding dll library to java using idea for using a program

I am trying to add and use a program called JVLC to my program. I downloaded a zip file that contains a jar file(jvlc.jar) for java interface and 2 dll files (jvlc.dll , libvlc.dll) and a folder that contains many dll files. when I run my program an UnsatisfiedLinkError occurs. I used this code to add those 2 dll files to my project.

System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\jvlc.dll");
System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\libvlc.dll");

but still there is error:

UnsatisfiedLinkError: Directory separator should not appear in library name

Is it necessary to add all folder to library paths? If yes how?

please guide me.

like image 914
sajad Avatar asked Mar 03 '26 07:03

sajad


1 Answers

The System.loadLibrary method loads a libary based on a library name (libName, without extension) and not through file name. Example, Java comes with a zip.dll / zip.so (Linux) that is used when we use the Zip Deflater/Inflater classes for zip files.

If you want to use specify a dll file name, use the System.load(String filename) method otherwise, register your DLL in a java lib path.

An example can be found here.


For your example, please do this:

//Your code....
System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\jvlc.dll");
System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\libvlc.dll");

//Replace with this...
System.load("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\jvlc.dll");
System.load("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\libvlc.dll");
like image 98
Buhake Sindi Avatar answered Mar 05 '26 21:03

Buhake Sindi