java系统库不加载opencv库 [英] The java system library do not load opencv library
问题描述
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
这样做很好,但现在我需要应用程序在服务器上运行,所以我做了一个maven简单的项目,在war中编译,并在依赖关系中添加了opencv,但是在上面的行中我得到这个错误。
导致:java.lang.UnsatisfiedLinkError:否java.library.path中的opencv_java249
我想这是真的,因为是一个maven依赖。
我如何解决这个问题?
这是我的pom.xml
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">
< modelVersion> 4.0.0< / modelVersion>
< groupId> org.springframework.samples< / groupId>
< artifactId> RetinoblastomappSpring< / artifactId>
< version> 0.0.1-SNAPSHOT< / version>
< packaging> war< / packaging>
< description> Tesis de diagnico temprano视网膜母细胞瘤< / description>
< properties>
<! - 通用属性 - >
< java.version> 1.8< / java.version>
< project.build.sourceEncoding> UTF-8< /project.build.sourceEncoding>
< project.reporting.outputEncoding> UTF-8< /project.reporting.outputEncoding>
<! - Spring - >
< spring-framework.version> 3.2.3.RELEASE< /spring-framework.version>
<! - Hibernate / JPA - >
< hibernate.version> 4.2.1.Final< / hibernate.version>
<! - 记录 - >
< logback.version> 1.0.13< /logback.version>
< slf4j.version> 1.7.5< /slf4j.version>
<! - 测试 - >
< junit.version> 4.11< / junit.version>
<! - OpenCV - >
< opencv.version> 2.4.9-4< /opencv.version>
< / properties>
<依赖关系>
<! - Spring和事务 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-context< / artifactId>
< version> $ {spring-framework.version}< / version>
< / dependency>
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-tx< / artifactId>
< version> $ {spring-framework.version}< / version>
< / dependency>
<! - 使用SLF4J& LogBack - >
<依赖关系>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-api< / artifactId>
< version> $ {slf4j.version}< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> ch.qos.logback< / groupId>
< artifactId> logback-classic< / artifactId>
< version> $ {logback.version}< / version>
< scope>运行时< / scope>
< / dependency>
<! - Hibernate - >
<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> $ {hibernate.version}< / version>
< / dependency>
<! - 测试工件 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> spring-test< / artifactId>
< version> $ {spring-framework.version}< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> $ {junit.version}< / version>
< scope> test< / scope>
< / dependency>
<! - OpenCV - >
<依赖关系>
< groupId> nu.pattern< / groupId>
< artifactId> opencv< / artifactId>
< version> $ {opencv.version}< / version>
< / dependency>
<依赖关系>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> exec-maven-plugin< / artifactId>
< version> 1.4.0< / version>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.3< / version>
< configuration>
< source> 1.8< / source>
< target> 1.8< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>
strong>
我手动添加了库,并且是一样的,战争正在编译OK,但是当我执行它,该行失败,我得到相同的错误
我看到我必须向我的系统变量添加opencv,但没有工作
您可以解决此问题,将文件opencv_java249.dll添加到文件夹java / bin /(已安装java的位置)
< (是的,这是我的答案,因为我想帮助有同样事情的人)
I'm using the opencv library in a java project. I have a simple java project that compiles as a 'jar', and manually adding the opencv library, then, I know that I have to put this code after nothing:
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
This works well, but now, I need the same application running in a server, so I made a maven simple project that compiles in a 'war' and added opencv in a dependency, but in the line above I get this error.
Caused by: java.lang.UnsatisfiedLinkError: no opencv_java249 in java.library.path
And I guess it is true because is a maven dependency. How I fix this?
Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>RetinoblastomappSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<description>Tesis de diagnostico temprano retinoblastoma</description>
<properties>
<!-- Generic properties -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Spring -->
<spring-framework.version>3.2.3.RELEASE</spring-framework.version>
<!-- Hibernate / JPA -->
<hibernate.version>4.2.1.Final</hibernate.version>
<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<!-- Test -->
<junit.version>4.11</junit.version>
<!-- OpenCV -->
<opencv.version>2.4.9-4</opencv.version>
</properties>
<dependencies>
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- Test Artifacts -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- OpenCV -->
<dependency>
<groupId>nu.pattern</groupId>
<artifactId>opencv</artifactId>
<version>${opencv.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
UPDATE
I added the library by hand, and is the same, The war is compiling OK, but when I execute it, that line fails and I get the same error.
I read that I have to add opencv to my system variables, but that didn't work
You can solve this issue adding the file "opencv_java249.dll" to the folder java/bin/ (where you have installed java)
(yes this is an answer to me, because I want to help somebody that has troubles on the same thing)
这篇关于java系统库不加载opencv库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!