I am trying a Maven Project with javacpp from Eclipse, and the project builds, but when I try to run it, it gives an exception and terminates itself. I am pretty new to Maven and managing pom.xml files, and I don't know what to do. The exception is:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniTest in java.library.path:
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2447)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:809)
at java.base/java.lang.System.loadLibrary(System.java:1893)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:1683)
at org.bytedeco.javacpp.Loader.load(Loader.java:1300)
at org.bytedeco.javacpp.Loader.load(Loader.java:1123)
at com.berk.maventest.Test.<clinit>(Test.java:13)
Below is my pom.xml file:
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.berk</groupId>
<artifactId>maventest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp-platform</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.3.1-1.5.4</version>
</dependency>
</dependencies>
</project>
And my Test.java file:
package com.berk.maventest;
import org.bytedeco.javacpp.*;
import org.bytedeco.javacpp.annotation.*;
@Platform(include = "Test.cpp")
@Namespace("TestLibrary")
public class Test extends Pointer{
static {
Loader.load();
}
public Test()
{
allocate();
}
private native void allocate();
public native int testMethod(int a);
public static void main(String [] args) {
//Calling the constructor
Test test = new Test();
//Calling the function
System.out.println("The answer is: " + test.testMethod(2));
//Calling the destructor
test.close();
}
}