I am using https://github.com/patternconsulting/opencv to include opencv 3.2.0 in my maven java project.
The issue that I am facing is that when i use mvn install
to generate a jar file and then run the jar file java -jar app.jar
i get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: nu/pattern/OpenCV
at com.example.Application.<clinit>(Application.java:21)
Caused by: java.lang.ClassNotFoundException: nu.pattern.OpenCV
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
below is an extract of my pom.xml file
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.2.0-1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<mainClass>com.example.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
and below is an extract of my class that has the main method:
public class Application {
static {
OpenCV.loadShared();
}
public Application() throws Exception {
// some code here
}
public static void main(String[] args) {
new Application();
}
any idea what might be causing this to happen and how to solve it?
Thanks