java.library.path 中没有 opencv_java300
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31286453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NO opencv_java300 in java.library.path
提问by Anuj
Thanks in advance..
提前致谢..
I have a project that uses opencv-300.jaras external library. I have tried this in eclipse and in natBeans.In both it is working successfully when I am running my project from IDE itself. I want my project to export it as a runnable (or executable) jar. I placed my opencv_java300.dllfile in source folder with main java file and given its name in
我有一个使用opencv-300.jar作为外部库的项目。我已经在 eclipse 和natBeans 中尝试过这个。当我从 IDE 本身运行我的项目时,它都运行成功。我希望我的项目将其导出为可运行(或可执行)的 jar。我将我的opencv_java300.dll文件放在带有主 java 文件的源文件夹中,并在
System.loadLibrary("opencv_java300");
I placed opencv-300.jar in external jar libraries and all other files which are needed in Main program. it is working successfully when running from IDE but when I am creating executable jar, it shows an error
我将 opencv-300.jar 放在外部 jar 库和主程序中需要的所有其他文件中。从 IDE 运行时它工作成功,但是当我创建可执行 jar 时,它显示错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
opencv_java300 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 CropFaceImage.main(CropFaceImage.java:27)
Please tell me Is there any way to give java.library.pathin program itself. My project is working sucsessfully even when I have removed path for opencv_java300.dllfile in external library.
请告诉我有没有办法在程序本身中提供java.library.path。即使我删除了外部库中opencv_java300.dll文件的路径,我的项目也能成功运行。
回答by Kalyan Chavali
You can use a command line argument as below and call your class which has the main
您可以使用如下命令行参数并调用您的类
java -Djava.library.path="Folder which contains your dll" ....
回答by Anuj
I tried to pass the command which contains path for opencvbut I found no other way. Somehow i tried something which created my jar and it is properly running. I copied the opencv_java300.dll file and put it in the directory which is next to the my jar file and did same for all supporting files. I used following code to do so.
我试图传递包含opencv路径的命令,但我没有找到其他方法。不知何故,我尝试了一些创建我的 jar 的东西,它正在正常运行。我复制了 opencv_java300.dll 文件并将其放在我的 jar 文件旁边的目录中,并对所有支持文件执行相同操作。我使用以下代码来做到这一点。
String opencvpath = System.getProperty("user.dir") + "\files\";
String libPath = System.getProperty("java.library.path");
System.load(opencvpath + Core.NATIVE_LIBRARY_NAME + ".dll");
回答by Hymanson William
I solved my problem when I've configured native library in eclipse. You need choose a library reference your OS platform.
当我在 eclipse 中配置本机库时,我解决了我的问题。您需要选择一个库引用您的操作系统平台。
Look at here: adding openCV to java buildpath in eclipse.
回答by nik_kobe
I had the same problem, solved it by switching the JRE System library. It seems like the problem occurs only if using jre1.8.0_65. Everything worked well by me with jre1.8.0_25, jre1.8.0.45 and jre1.8.0.66
我遇到了同样的问题,通过切换 JRE 系统库解决了它。似乎只有在使用 jre1.8.0_65 时才会出现问题。我用 jre1.8.0_25、jre1.8.0.45 和 jre1.8.0.66 一切正常
回答by AldaronLau
I was able to fix the error by removing my System.loadLibrary("opencv_java300");
From the code and adding the jar file to the classpath in my build.xml:
我能够通过删除我的System.loadLibrary("opencv_java300");
From 代码并将 jar 文件添加到我的 build.xml 中的类路径来修复错误:
<jar destfile="program.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="com.src.program"/>
<attribute name="Class-path" value="opencv-300.jar"/>
</manifest>
</jar>