UnsatisfiedLinkError:java.library.path 中没有 opencv_java249 [英] UnsatisfiedLinkError: no opencv_java249 in java.library.path

查看:64
本文介绍了UnsatisfiedLinkError:java.library.path 中没有 opencv_java249的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 mac 上运行一段代码时遇到一些问题.有人给我写了一个图像分析 Java 应用程序,但我在尝试在 netbeans 上运行它时不断收到此错误.

Running into some problems making a piece of code run on my mac. Had someone write me an image analysis java app but I keep getting this error when trying to run it on netbeans.

运行:线程main"中的异常java.lang.UnsatisfiedLinkError:否opencv_java249 在 java.library.path 处java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) atjava.lang.Runtime.loadLibrary0(Runtime.java:870) 在java.lang.System.loadLibrary(System.java:1119) 在image.prossing.Test.main(Test.java:28) Java 结果:1 构建成功(总时间:0秒)

run: Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857) at java.lang.Runtime.loadLibrary0(Runtime.java:870) at java.lang.System.loadLibrary(System.java:1119) at image.prossing.Test.main(Test.java:28) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds)

有 netbeans 项目,并添加必要的 jar 文件作为库.程序员告诉我下载正确的 OpenCV 版本并将 opencv.dll 文件复制到我的 java/jre/bin 文件夹中.但是我找不到 dll 文件或 java/jre 文件夹.我知道大多数编程发生在 Windows 上是有原因的.希望有人能帮我解决这个问题并在我的 Mac 上运行这个应用程序.

Have the netbeans project, and added the necessary jar files as libraries. The programmer told me to download the correct OpenCV version and copy the opencv.dll file to my java/jre/bin folder. But I cannot find the dll file or the java/jre folder. I know most programming happens on windows for a reason. Hope someone can help me resolve this issue and run this application on my mac.

这是代码的第一部分,最有可能产生错误的部分:

Here is the first part of the code, the part that is most probably creating the error:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package image.prossing;

/**
 *
 * @author Dumith Salinda
 */
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.Core;
import static org.opencv.core.Core.FONT_HERSHEY_SIMPLEX;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;

public class Test {

public static void main(String[] args) {

    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

对不起,如果不是很清楚,如果有什么遗漏或不清楚,请告诉我要添加哪些信息.非常感谢您能提供的任何帮助.真挚地梅尔沃塞尔

Sorry if it's not that clear, let me know what info to add if something is missing or not clear. Would truly appreciate any help you could give. Sincerely Meir Warcel

推荐答案

查看你的 OpenCV 目录;

Look into your OpenCV directory;

举个例子;(使用 brew install opencv3 --with-java --with-python3 安装)

For an example this; (installed using brew install opencv3 --with-java --with-python3)

/usr/local/Cellar/opencv3/XXX/share/OpenCV/java

你会看到;

libopencv_javaXXX.so    opencv-XXX.jar

既然您已经编译了 OpenCV 的 Java 原生库 (libopencv_javaXXX.so),唯一剩下的就是 mac 的动态库.

Now that you already have OpenCV's native library for Java (libopencv_javaXXX.so) compiled with you, the only thing left is, mac's dynamic library.

libopencv_javaXXX.so链接到libopencv_javaXXX.dylib

ln -s libopencv_javaXXX.so libopencv_javaXXX.dylib

现在添加 /usr/local/Cellar/opencv3/XXX/share/OpenCV/java 作为 Native Library LocationsIntelliJ 或其他东西在 Eclipse 中类似.

Now add /usr/local/Cellar/opencv3/XXX/share/OpenCV/java as Native Library Locations in IntelliJ or something similar in Eclipse.

或者将其添加到您的 JVM 参数中;

Or add this to your JVM arguments;

-Djava.library.path=/usr/local/Cellar/opencv3/XXX/share/OpenCV/java

这篇关于UnsatisfiedLinkError:java.library.path 中没有 opencv_java249的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆