Cannot fix vlcj load library 'libvlc'

徘徊边缘 提交于 2021-02-19 06:13:41

问题


i am using netbeans to use vlcj jar my jdk is jdk-7u45-windows-x64 and my vlc is 64b i installed the library by going to libraries then right Click on the libraries file then add jar/folder and i added the file i download it from here file link the file name vlcj-3.0.0-dist.zip i unzip it then add it by select them all the code for test is this

    package translater;
import uk.co.caprica.vlcj.binding.LibVlc;
import uk.co.caprica.vlcj.runtime.RuntimeUtil;
import com.sun.jna.Native;


/**
 *
 * @author isslam
 */
public class Translater {


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        GuiClass is = new GuiClass("AnimeFactor");
        is.setVisible(true);

        Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);


    }

}

the error message is this

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'libvlc': JNA native support (win32-amd64/libvlc.dll) not found in resource path (C:\Users\isslam\Desktop\vlcj-2.4.1-dist\vlcj-2.4.1\jna-3.5.2.jar;C:\Users\isslam\Desktop\vlcj-2.4.1-dist\vlcj-2.4.1\platform-3.5.2.jar;C:\Users\isslam\Desktop\vlcj-2.4.1-dist\vlcj-2.4.1\vlcj-2.4.1.jar;C:\Users\isslam\Documents\NetBeansProjects\translater\build\classes)
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:220)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:322)
at com.sun.jna.Library$Handler.<init>(Library.java:142)
at com.sun.jna.Native.loadLibrary(Native.java:387)
at com.sun.jna.Native.loadLibrary(Native.java:366)
at translater.Translater.main(Translater.java:27)

回答1:


vlcj has a dependency on JNA.

You therefore need to add the JNA and JNA Platform jar files to your project. How you do this depends on your own project and the IDE your are using. The most basic way to do this is to download the jar files from the links [1] and [2] and copy them to the same directory that contains the vlcj jar file.

The manifest class path declared inside the vlcj jar file refers to these JNA jars - this means that you should just need to make sure the jar files are copied to the correct place in your project, you should not have to explicitly add them to your project class path.

My view is it's simpler if you use Maven, but anyway...

After you have installed the libraries correctly, your next problem is get your JVM to load the native libraries.

You can get an UnsatisfiedLinkError for a number of reasons, the most common being:

  1. The shared object (DLL) you are trying to load simply could not be found;
  2. You are trying to mix CPU architectures, i.e. your JVM is 64-bit, but your native libraries are 32-bit (or vice versa). This can never work.

When loading a native library with JNA, there are a number of ways to set the search path...

This is explained in [3], but to summarise here the simplest way is to add some code like this to your application:

NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), "the-directory");

This statement tells JNA to look in a particular directory to find the LibVLC shared objects (DLLs on Windows).

You replace the literal string "the-directory" with the full path to the directory on your disk that contains the libvlc.dll and libvlccore.dll files (or equivalent .so files if you're on Linux).

There is no 64-bit or 32-bit version of vlcj - it's just platform independant Java.

[1]: http://search.maven.org/#artifactdetails%7Cnet.java.dev.jna%7Cjna%7C4.0.0%7Cjar

[2]: http://search.maven.org/#artifactdetails%7Cnet.java.dev.jna%7Cjna-platform%7C4.0.0%7Cjar

[3]: http://www.capricasoftware.co.uk/projects/vlcj/tutorial1.html

The above dependencies (and links to the artefacts) are correct if you are using vlcj 3.0.0 or later. If you are using an earlier version of vlcj such as 2.4.1, then you need to use JNA and JNA Platform version 3.5.2 instead of 4.0.0.




回答2:


right but my problem was with the jvm it was i think 32b so i change it by downloade it form here java jvm this page have the 32 and 64 type



来源:https://stackoverflow.com/questions/21066731/cannot-fix-vlcj-load-library-libvlc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!