Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To build Java project with OpenCV using Maven

I need to build the project, which involv an OpenCV. It would be great, but libraries don't get into the library java.library.path for some reason. And when I try to run the code using the library I get this error:

*java.lang.UnsatisfiedLinkError: no jniopencv_highgui in java.library.path*

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>ru.intemsys.reget.server</groupId>
  <artifactId>reget-server</artifactId>
  <version>0.1-alpha</version>
  <packaging>jar</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.build.timestamp.format>yyyyMMddhhmm</maven.build.timestamp.format>
    <platform.name>${os.name}-${os.arch}</platform.name>
    <product.year>2014</product.year>
    <jdkVersion>1.6</jdkVersion>
    <javacpp.version>0.7</javacpp.version>
    <javacv.version>0.7</javacv.version>
  </properties>

  <dependencies>
    <dependency>
        <groupId>commons-daemon</groupId>
        <artifactId>commons-daemon</artifactId>
        <version>1.0.10</version>
    </dependency>

      <dependency>
          <groupId>com.googlecode.javacpp</groupId>
          <artifactId>javacpp</artifactId>
          <version>${javacpp.version}</version>
      </dependency>
      <dependency>
          <groupId>com.googlecode.javacv</groupId>
          <artifactId>javacv</artifactId>
          <version>${javacv.version}</version>
      </dependency>
      <dependency>
          <groupId>com.googlecode.javacv</groupId>
          <artifactId>javacv</artifactId>
          <version>${javacv.version}</version>
          <classifier>linux-x86</classifier>
      </dependency>

      <dependency>
          <groupId>com.googlecode.javacv</groupId>
          <artifactId>javacv</artifactId>
          <version>${javacv.version}</version>
          <classifier>linux-x86_64</classifier>
      </dependency>

    <dependency>
        <groupId>com.xeiam.xchart</groupId>
        <artifactId>xchart</artifactId>
        <version>2.3.1</version>
    </dependency>

    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
      <repository>
          <id>javacpp</id>
          <name>JavaCPP</name>
          <url>http://maven2.javacpp.googlecode.com/git/</url>
      </repository>
      <repository>
          <id>javacv</id>
          <name>JavaCV</name>
          <url>http://maven2.javacv.googlecode.com/git/</url>
      </repository>
  </repositories>

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${jdkVersion}</source>
                    <target>${jdkVersion}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>compile</includeScope>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <classpathLayoutType>simple</classpathLayoutType>
                            <mainClass>ru.intemsys.reget.server.App</mainClass>
                            <packageName>ru.intemsys.reget.server</packageName>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <finalName>${artifactId}-${version}</finalName>
                </configuration>
            </plugin>
        </plugins>
  </build>

    <profiles>
        <profile>
            <id>linux</id>
            <activation>
                <os><name>linux</name></os>
            </activation>
            <properties>
                <os.name>linux</os.name>
            </properties>
        </profile>
        <profile>
            <id>macosx</id>
            <activation>
                <os><name>mac os x</name></os>
            </activation>
            <properties>
                <os.name>macosx</os.name>
            </properties>
        </profile>
        <profile>
            <id>windows</id>
            <activation>
                <os><family>windows</family></os>
            </activation>
            <properties>
                <os.name>windows</os.name>
            </properties>
        </profile>
        <profile>
            <id>i386</id>
            <activation>
                <os><arch>i386</arch></os>
            </activation>
            <properties>
                <os.arch>x86</os.arch>
            </properties>
        </profile>
        <profile>
            <id>i486</id>
            <activation>
                <os><arch>i486</arch></os>
            </activation>
            <properties>
                <os.arch>x86</os.arch>
            </properties>
        </profile>
        <profile>
            <id>i586</id>
            <activation>
                <os><arch>i586</arch></os>
            </activation>
            <properties>
                <os.arch>x86</os.arch>
            </properties>
        </profile>
        <profile>
            <id>i686</id>
            <activation>
                <os><arch>i686</arch></os>
            </activation>
            <properties>
                <os.arch>x86</os.arch>
            </properties>
        </profile>
        <profile>
            <id>amd64</id>
            <activation>
                <os><arch>amd64</arch></os>
            </activation>
            <properties>
                <os.arch>x86_64</os.arch>
            </properties>
        </profile>
        <profile>
            <id>x86-64</id>
            <activation>
                <os><arch>x86-64</arch></os>
            </activation>
            <properties>
                <os.arch>x86_64</os.arch>
            </properties>
        </profile>
    </profiles>
</project>

mvn -version

Apache Maven 3.0.4 Maven home: /usr/share/maven Java version: 1.7.0_25, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-7-openjdk-i386/jre Default locale: ru_RU, platform encoding: UTF-8 OS name: "linux", version: "3.11.0-14-generic", arch: "i386", family: "unix"

uname -a

Linux PC-1 3.11.0-14-generic #21-Ubuntu SMP Tue Nov 12 17:07:40 UTC 2013 i686 i686 i686 GNU/Linux

like image 201
ftp27 Avatar asked Nov 01 '22 02:11

ftp27


1 Answers

There is a solution. All libs are in javacv-0.6-cppjars.zip

like image 111
ftp27 Avatar answered Nov 15 '22 05:11

ftp27