简体   繁体   English

使用想法使用程序将dll库添加到java

[英]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 : 根据本教程

  • You need to set LD_LIBRARY_PATH (on Linux/Unix) or PATH (Windows) include the directory where the libraries are. 您需要设置LD_LIBRARY_PATH (在Linux / Unix上)或PATH (Windows)包括库所在的目录。
  • You don't need the .dll suffix. 您不需要.dll后缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Window bat 脚本启动 java 程序加载 dll 失败,但使用 IntelliJ IDEA 成功启动? - Window bat script start java program loading dll failed, but successfully started using IntelliJ idea? 在Android Studio中使用Java库的难度,在IDEA中工作正常 - Difficulty using java library in Android Studio, works fine in IDEA 使用javaaddpath将Java库添加到MATLAB中 - Adding java library into MATLAB using javaaddpath 使用Java库的Funtime错误要求我拥有JRE 8,但使用IDEA的Library需要JDK 6 - Funtime errors using a Java Library requires me to have JRE 8, but Library requires JDK 6 using IDEA 使用 maven 将 dll 添加到 java.library.path - Add dll to java.library.path using maven 使用Apache Tika库进行Java程序编译-依赖项 - Java program compile using Apache Tika library - dependencies 将 GUI 添加到视频播放程序(在使用 Java 处理中) - Adding a GUI to a Video-playing program (in Processing using Java) 使用 jxl 库向带有 Java 的 Excel 文件中的单元格添加注释 - Adding a comment to a cell in an Excel file with Java using jxl library 使用Java中的COM .dll而不使用regsvr32注册库 - Using a COM .dll from Java without registering the library using regsvr32 Intellij 没有将 VTK library.dll 依赖项添加到 Java 项目 - Intellij not adding VTK library .dll dependency to Java project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM