使用idea向java添加dll库以使用程序
我正在尝试将一个名为 JVLC 的程序添加并使用到我的程序中。我下载了一个zip文件,其中包含一个用于java接口的jar文件(jvlc.jar)和2个dll文件(jvlc.dll,libvlc.dll)以及一个包含许多dll文件的文件夹。当我运行程序时,会发生 UnsatisfiedLinkError 。 我使用此代码将这 2 个 dll 文件添加到我的项目中。
System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\jvlc.dll");
System.loadLibrary("C:\\Users\\sajad\\Documents\\Downloads\\Compressed\\JVLC\\libvlc.dll");
但仍然有错误:
UnsatisfiedLinkError:目录 分隔符不应出现在库中 姓名
是否需要将所有文件夹添加到库路径中?如果是的话怎么办?
请指导我。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
System.loadLibrary
方法根据库名称(libName,不带扩展名)加载库,不通过文件名加载库。例如,Java 附带了 zip.dll / zip.so (Linux),当我们对 zip 文件使用 Zip Deflater/Inflater 类时,就会使用该文件。如果要使用指定 dll 文件名,请使用 System.load(String filename) 方法,否则,请在 java lib 路径中注册 DLL。
可以在此处找到示例。
对于您的示例,请执行以下操作:
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:
根据本教程:
LD_LIBRARY_PATH
(在 Linux/Unix 上)或PATH
(Windows) 包含库所在的目录。.dll
后缀。According to this tutorial:
LD_LIBRARY_PATH
(on Linux/Unix) orPATH
(Windows) include the directory where the libraries are..dll
suffix.