如何使用 JVLC(VLC 的 Java 绑定)?
我正在尝试使用 JVLC 但我似乎无法让它工作。 我已经下载了 jar,安装了 VLC 并将 -D 参数传递给 JVM 告诉它VLC 安装位置。 我也尝试过:
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files\\VideoLAN\\VLC");
没有运气。 我总是得到:
线程“main”中出现异常 java.lang.UnsatisfiedLinkError:无法 加载库“libvlc”: 找不到指定的模块。
有人让它发挥作用吗?
I'm trying to use JVLC but I can't seem to get it work. I've downloaded the jar, I installed VLC and passed the -D argument to the JVM telling it where VLC is installed. I also tried:
NativeLibrary.addSearchPath("libvlc", "C:\\Program Files\\VideoLAN\\VLC");
with no luck. I always get:
Exception in thread "main"
java.lang.UnsatisfiedLinkError: Unable
to load library 'libvlc': The
specified module could not be found.
Has anyone made it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您
至少应该尝试验证您的库是否可以加载。
如果没有,它可能会给你有用的错误消息(对我来说就是这样)。
(正如 Sipe 提到的,您可能使用 64 位 JRE/JDK,在这种情况下,将永远找不到 libvlc(它只是 32 位)。在这种情况下,您必须切换到使用 32 位 JRE/JDK。)
You should try
at least to verify that your library can be loaded.
And if not, it may give you useful error messages (it did for me).
(And as Sipe mentioned, you may be using a 64 bits JRE/JDK, in which case libvlc will never be found (it's 32 bits only). In this case you must switch to using a 32 bits JRE/JDK.)
如果您尝试加载的 dll 需要其他不可用的 dll,则可能会出现该异常。 抱歉,我无法提供更具体的帮助,但这是值得检查的事情。 您可以使用 depends 来遍历 dll 依赖项。
You can get that exception if the dll you are trying to load requires other dlls that are not available. Sorry I can't be of more specific help, but it is something to check out. You can use depends to walk the dll dependancies.
不确定 NativeLibrary 类。 通常,在使用本机库时,您需要将系统属性“java.library.path”设置为本机库的位置。 正如所建议的,如果您的本机库(dll、so 等)依赖于其他本机库,那么操作系统将接管以解决这些依赖关系。 操作系统将不知道 java.library.path 并开始搜索本机库的操作系统特定路径。 在 Windows 上,这包括当前的 PATH 环境变量以及 windows 目录中的 System32。 在 Linux 上,这是 LD_LIBRARY_PATH / ld.conf 设置。
尝试将 PATH (LD_LIBRARY_PATH) 设置为指向与 java.library.path 相同的位置。 唯一的问题是你不能设置你的进程启动(JVM),已经太晚了。 您需要在 JVM 启动之前设置环境。 您可以通过批处理文件、shell 脚本、Ant 或直接从 IDE 来执行此操作。
Not sure about that NativeLibrary class. Typically when using native libraries, you need to set the system property, "java.library.path", to the location of your native libraries. As suggested, if your native library (dll, so, etc) depends on additional native libraries then the OS will takeover to resolve these dependencies. The OS will have no clue about java.library.path and beging by searching the OS specific path for native libraries. On windows this includes the current PATH environment variable as well as System32 in the windows directory. On linux this is the LD_LIBRARY_PATH / ld.conf setup.
Try setting the PATH (LD_LIBRARY_PATH) to point to the same location as java.library.path. The only catch is that you can't set this one your process launches (the JVM), it's already too late. You need to have the environment set BEFORE the JVM launches. You can do this vis batch files, shell scripts, Ant, or directly from your IDE.
我也遇到了同样的问题,我注意到它只发生在 64 位 jdk/jre 上。
在 Win7 x64 下与 32 位 jdk 一样使用 charm。
祝你编码愉快!
-刀槽花纹
I had the same problem too and I noticed that it occured only with 64-bit jdk/jre.
Works like charm with 32-bit jdk under Win7 x64.
Have a nice coding!
-Sipe