开发者

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 proje开发者_如何学编程ct.

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.


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");


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜