3

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.

PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
sajad
  • 2,094
  • 11
  • 32
  • 52

2 Answers2

6

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");
Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
  • Yes! I deleted file name at the end of System.loadLibrary("C:\..."). but still it doesn't work. How can I add all library to my project? I also used "System.load(filename)" but still error :jvlc.dll: Can't find dependent libraries – sajad Oct 18 '10 at 16:44
  • 1
    @sajad you need to find the libraries upon which your libraries depend and load them first. – Bruno Oct 18 '10 at 23:17
0

According to this tutorial:

  • You need to set LD_LIBRARY_PATH (on Linux/Unix) or PATH (Windows) include the directory where the libraries are.
  • You don't need the .dll suffix.
Bruno
  • 119,590
  • 31
  • 270
  • 376