简体   繁体   中英

How to use JVLC (Java bindings for VLC)?

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?

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.

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.

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

You should try

System.load("C:\\Path\\To\\libvlc.dll");

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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM