使用idea向java添加dll库以使用程序

发布于 2024-09-27 14:59:38 字数 543 浏览 2 评论 0原文

我正在尝试将一个名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岛徒 2024-10-04 14:59:38

System.loadLibrary 方法根据库名称(libName,不带扩展名)加载库,通过文件名加载库。例如,Java 附带了 zip.dll / zip.so (Linux),当我们对 zip 文件使用 Zip Deflater/Inflater 类时,就会使用该文件。

如果要使用指定 dll 文件名,请使用 System.load(String filename) 方法,否则,请在 java lib 路径中注册 DLL。

可以在此处找到示例。


对于您的示例,请执行以下操作:

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

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");
百变从容 2024-10-04 14:59:38

根据本教程

  • 您需要设置LD_LIBRARY_PATH(在 Linux/Unix 上)或 PATH (Windows) 包含库所在的目录。
  • 您不需要 .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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文