3

I am trying make a messenger program in Java that has a video player in it, so I'm using vlcj. But I receive this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
Unable to load library 'libvlc':
The specified module could not be found.

I have followed the tutorials from here, but I still get this error. This is the only error that I get.

I'm running on Windows 7 x64 Ultimate with a x64 VLC. I'm coding using the latest Eclipse version.

Can anyone guide me step-by-step on how to fix this?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
wutang
  • 31
  • 1
  • 1
  • 2
  • please follow the steps in this link [playing media file mp4 file][1] [1]: http://stackoverflow.com/questions/10085522/playing-media-files-using-java – Areeg Samir Oct 21 '13 at 03:22

7 Answers7

3

you have to add "libvlc" and "libvlccore" dll path in your application. these will be present into your vlc installation folder. you can add following line of code to get it working.

NativeLibrary.addSearchPath("libvlc", "C:/VideoLAN/VLC");

here "C:/VideoLAN/VLC" is installation folder of vlc.

Imrank
  • 1,009
  • 5
  • 15
1

I read the vlcj instructions you posted.

It seems the vlcj library is using JNA and you can setup the library search path using the NativeLibrary class as is stated in the check program:

import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;

import com.sun.jna.Native;
import com.sun.jna.NativeLibrary;

public class Tutorial1A {
    public static void main(String[] args) {
        String vlcHome = "dir/with/dlls"; // Dir with vlc.dll and vlccore.dll
        NativeLibrary.addSearchPath(
            RuntimeUtil.getLibVlcLibraryName(), vlcHome
        );
        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
    }
}

Yo can try to run that code and check if it completes without exceptions.

vlcj instructions also points out that the architecture of the JRE is relevant; you should check your JRE architecture by typing:

java -version

The JRE architecture should match the VLC one (maybe you can check the VLC architecture in the About dialog). Both should be equal (32b or 64b).

However, it is strange that the error message refers to libvlc instead vlc or vlccore being executed in Windows.

Anyway, if adding the VLC path to the search path using NativeLibrary don't work and the JRE architecture matches the VLC one, you can add the code you are using to try to find out more.

Optimus Prime
  • 6,817
  • 5
  • 32
  • 60
jaguililla
  • 1,916
  • 18
  • 21
  • Both my JRE and VLC are 64b so that doesn't trigger the problem and I also used NativeLibrary search and still I get that error. I tried everything that is on that webpage and still the same error. Furthermore, the .dll files from the VLC folder are name .dll.a so I changed them to .dll when I placed them in jre/bin and still the same error. Should I change them to .dll in the VLC folder as well? – wutang Jan 15 '13 at 10:33
  • Your VLC installation should have `libvlc.dll` and `libvlccore.dll` in some folder. The .a extension seems like a Linux binary. If the file you have is: `libvlc.dll.a` probably you are not pointing to the correct VLC folder or not using the VLC program for your SO. VLC 2.0.5 for Windows have a file `libvlc.dll` in the program folder (without the `.a`) – jaguililla Jan 28 '13 at 22:32
1

This is how you load the vlc libraries using JNA:

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "Path to native library");

For my program I have the vlc "libvlc.dll" and "vlccore.dll" located in a sub-folder lib/VLC/ so I load the files relative to my "program.jar" using System.getProperty("user.dir") and adding the path to the end:

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), System.getProperty("user.dir") + "/lib/VLC");

If you want to load the library from the default VLC install path in windows 7 you can do it as follows:

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files (x86)/VideoLAN/VLC");

Edit: If you run this code from within eclipse it will not work, unless you specify an absolute path to the VLC library files. If you want to test a relative path then first build the jar file and place it in the correct folder relative to the VLC library files.

sorifiend
  • 5,927
  • 1
  • 28
  • 45
1

Make sure you are using either a straight x64 or x32 environment. This means:

  • Windows x64 (obviously)
  • Java JRE x64 (do not install a second x32 JRE)
  • Java JDK x64
  • VLC x64

Now you should be fine.

0

As the error indicates, the JVM is attempting to load the native library "libvlc.dll", but is unable to locate it.

Either place the dll in the .../jre/bin directory in your java install, or use the java.library.path property to point to it's location.

See also How to add native library to "java.library.path" with Eclipse launch (instead of overriding it)

Community
  • 1
  • 1
pap
  • 27,064
  • 6
  • 41
  • 46
  • 1
    I placed the dll in the jre/bin but still doesn't work. How do I use the java.library.path property? – wutang Jan 14 '13 at 15:29
0

Set the path with the jna.library.path system property. A working example of this technique can be found at:

https://github.com/johndeverall/BehaviourCoder/blob/master/src/main/java/de/bochumuniruhr/psy/bio/behaviourcoder/Main.java

in the public static void main(String[] args) method.

This code is likely to be updated soon which will destroy the above link but you can always use version control to go back to the date I posted this and take a look at the code.

John Deverall
  • 5,954
  • 3
  • 27
  • 37
0
cd src/main/resources/
cp -r /Applications/VLC.app/Contents/MacOS/lib darwin
rm darwin/*.*.*
cd darwin
install_name_tool -add_rpath @loader_path libvlc.dylib
mkdir vlc
cp -r /Applications/VLC.app/Contents/MacOS/plugins vlc/plugins

This is the macOS version. Maybe help you.

├── kotlin
│   └── App.kt
└── resources
    └── darwin
        ├── libvlc.dylib
        ├── libvlccore.dylib
        └── vlc
            └── plugins
                ├── liba52_plugin.dylib
                ├── libaccess_concat_plugin.dylib
                ├── libaccess_imem_plugin.dylib
                ├── libaccess_mms_plugin.dylib
BaiJiFeiLong
  • 3,716
  • 1
  • 30
  • 28