[英]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. 我正在尝试添加和使用一个名为JVLC的程序到我的程序中。 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.
我下载了一个zip文件,其中包含用于java接口的jar文件(jvlc.jar)和2个dll文件(jvlc.dll,libvlc.dll)以及包含许多dll文件的文件夹。 when I run my program an UnsatisfiedLinkError occurs.
当我运行我的程序时,会出现UnsatisfiedLinkError。 I used this code to add those 2 dll files to my project.
我用这段代码将这两个dll文件添加到我的项目中。
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
UnsatisfiedLinkError:目录分隔符不应出现在库名称中
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. System.loadLibrary
方法基于库名称( libName ,没有扩展名)而不是文件名来加载库。 Example, Java comes with a zip.dll / zip.so (Linux) that is used when we use the Zip Deflater/Inflater classes for zip files. 例如,Java附带了一个zip.dll / zip.so(Linux),当我们使用Zip Deflater / Inflater类来获取zip文件时使用它。
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. 如果要使用指定dll文件名,请使用
System.load(String filename)
方法,否则,请在java lib路径中注册DLL。
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 : 根据本教程 :
LD_LIBRARY_PATH
(on Linux/Unix) or PATH
(Windows) include the directory where the libraries are. LD_LIBRARY_PATH
(在Linux / Unix上)或PATH
(Windows)包括库所在的目录。 .dll
suffix. .dll
后缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.