简体   繁体   English

线程“main”中的异常 java.lang.UnsatisfiedLinkError:java.library.path 中没有 opencv_java249

[英]Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path

I'm currently trying to set up OpenCV on my 32-bit laptop, but I keep getting an error message which is confusing me:我目前正在尝试在我的 32 位笔记本电脑上设置 OpenCV,但我不断收到一条让我感到困惑的错误消息:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at hello.main(hello.java:8)

I've tried switching a few things around, like going into User Libraries and changing the Native Library Location to \x64 instead of \x86, but that hasn't worked.我试过改变一些东西,比如进入用户库并将本机库位置更改为 \x64 而不是 \x86,但这没有用。 I've also made sure that my Java project has OpenCV-2.4.9 as one of its libraries, which it has.我还确保我的 Java 项目将 OpenCV-2.4.9 作为它拥有的库之一。 I've also tried 'cleaning' all projects, but that hasn't worked (does it ever?).我也试过“清理”所有项目,但没有奏效(有过吗?)。 So I've followed all the instructions in the set-up tutorial but it still isn't working.所以我已经按照设置教程中的所有说明进行操作,但它仍然无法正常工作。

Does anyone know what the problem might be here?有谁知道这里可能有什么问题? Thanks in advance...提前致谢...

The problem is that the native opencv library cannot be found because it is not in the java.library.path (it is a native library and it should not be in usual java classpath, but it must be in the java.library.path).问题是找不到本机opencv库,因为它不在java.library.path (它是本机库,不应在通常的java类路径中,但必须在java.library.path中) .

Your opencv distribution should contains:您的 opencv 发行版应包含:

  • a java library : opencv249.jar.一个java库:opencv249.jar。 This library is mainly a java to native library with jni stuff allowing you to do native calls from java code.这个库主要是一个 Java 到本机库,带有 jni 内容,允许您从 Java 代码进行本机调用。 It must be in the classpath (and according the error you have and your explanations : it is on your classpath --> everything is ok here)它必须在类路径中(并且根据您的错误和您的解释:它在您的类路径中 --> 此处一切正常)

  • a native library named libopencv_java249.so and this must be in your java.library.path .一个名为libopencv_java249.so的本机库,它必须在您的java.library.path Obviously : it is not : the UnsatisfiedLinkError is the symptom of a missing native library.显然:它不是:UnsatisfiedLinkError 是缺少本机库的症状。 To include this native library: start your java program with the following parameter:要包含此本机库:使用以下参数启动您的 java 程序:

    -Djava.library.path=/path/to/the/directory/of/ibopencv_java249.so -Djava.library.path=/path/to/the/directory/of/ibopencv_java249.so

在 Ubuntu 上对我libopen.so另一种可能的解决方案:不要将 JVM 参数设置为确切的libopen.so文件,而是尝试将其设置为文件夹:

-Djava.library.path=/opencv-3.2.0/opencv/build/lib/

good day!i saw this one from the other forum.美好的一天!我在另一个论坛上看到了这个。

How to set the java.library.path from Eclipse 如何从 Eclipse 设置 java.library.path

i found out that you should copy the .dll file from your opencv and paste it to your windows folder.我发现您应该从 opencv 复制 .​​dll 文件并将其粘贴到 Windows 文件夹中。 to do that, kindly locate the .dll from this path folder为此,请从此路径文件夹中找到 .dll

opencv>build>java>x64 (for 64bit platform) or opencv>build>java>x86 (for x86/32 bit platform). opencv>build>java>x64(64 位平台)opencv>build>java>x86(x86/32 位平台)。

copy the .dll file and paste it to your windows folder ( c:/windows ) after that you may recompile your work to check if it works.复制 .dll 文件并将其粘贴到您的 windows 文件夹 ( c:/windows ) 之后,您可以重新编译您的工作以检查它是否有效。

* note this tutorial is applicable only if you already set the .jar file of opencv to the preference setting of eclipse. *注意本教程仅适用于您已经将 opencv 的 .jar 文件设置为 eclipse 的首选项设置的情况。

this method works for me.这种方法对我有用。

Using Java in Netbeans, when including在 Netbeans 中使用 Java,当包含

-Djava.library.path="E:\Program Files\opencv\build\java\x64" 

in the Project Property>Run I just forgot the double quotes between the path.Project Property>Run我只是忘记了路径之间的双引号。 Add double quotes then everything worked fine.添加双引号然后一切正常。

I had the same issue on ubuntu 14.o and I struggled a lot and found this solution.我在 ubuntu 14.o 上遇到了同样的问题,我很挣扎并找到了这个解决方案。

  1. use below line to print your Native lib path: System.out.println(System.getProperty("java.library.path"));使用下面的行打印您的本地库路径: System.out.println(System.getProperty("java.library.path"));
  2. if you are adding external openc4-version.jar then, in eclipse open BuildConfigurationPath->Library->opencv249.jar->Native Library and click edit and choose external folder which will be located inside /home/dav/Downloads/opencv-2.4.9/build/lib如果要添加外部 openc4-version.jar,则在 Eclipse 中打开 BuildConfigurationPath->Library->opencv249.jar->Native Library 并单击编辑并选择位于 /home/dav/Downloads/opencv-2.4 内的外部文件夹.9/构建/库

Before this I built opencv as they metioned in java-opencv quickstart tutorial by creating build folder inside opencv unziped folder then ran 2 commands 1.cmake -DBUILD_SHARED_LIBS=OFF .. if you get error then check make installed or not 2.make -j8在此之前,我在 java-opencv 快速入门教程中通过在 opencv 解压缩文件夹中创建构建文件夹来构建 opencv,然后运行 ​​2 个命令 1.cmake -DBUILD_SHARED_LIBS=OFF .. 如果出现错误,请检查是否安装了 make 2.make -j8

Done.完毕。

暂无
暂无

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

相关问题 UnsatisfiedLinkError:java.library.path 中没有 opencv_java249 - UnsatisfiedLinkError: no opencv_java249 in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有opencv_java2410 - Exception in thread “main” java.lang.UnsatisfiedLinkError: no opencv_java2410 in java.library.path 线程“主”java.lang.UnsatisfiedLinkError 中的异常:java.library.path 中没有 opencv_java451: - Exception in thread “main” java.lang.UnsatisfiedLinkError: no opencv_java451 in java.library.path: 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有libz3java - Exception in thread “main” java.lang.UnsatisfiedLinkError: no libz3java in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有libopencv_java247 - Exception in thread “main” java.lang.UnsatisfiedLinkError: no libopencv_java247 in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有indri_jni - Exception in thread “main” java.lang.UnsatisfiedLinkError: no indri_jni in java.library.path 线程“main”中的异常 java.lang.UnsatisfiedLinkError:java.library.path 中没有 lpsolve55j - Exception in thread “main” java.lang.UnsatisfiedLinkError: no lpsolve55j in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有终端 - Exception in thread “main” java.lang.UnsatisfiedLinkError: no Terminal in java.library.path 线程“main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有jpcap - Exception in thread “main” java.lang.UnsatisfiedLinkError: no jpcap in java.library.path 线程“ main”中的异常java.lang.UnsatisfiedLinkError:java.library.path中没有lwjgl-devil - Exception in thread “main” java.lang.UnsatisfiedLinkError: no lwjgl-devil in java.library.path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM