0

I am getting this error when trying to run my app from the terminal (after compiling it into a jar, using maven install):

Exception in thread "main" java.lang.NoClassDefFoundError: org/bytedeco/javacv/OpenCVFrameGrabber
    at org.wcapture.server.WCapture.captureFrame(WCapture.java:17)
    at org.wcapture.server.App.main(App.java:17)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacv.OpenCVFrameGrabber
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

However, when running it in Eclipse it works perfectly fine.

It seems that maven doesn't include the dependencies when compiling the app to a jar.

I'd appreciate any help with this. Thank you.

NakedCat
  • 852
  • 1
  • 11
  • 40
  • Which builder plugin (if any) is defined in the pom? [This](https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-mavenhttps://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) might help. – Andrew S May 01 '18 at 13:54
  • @AndrewS `maven-jar-plugin`, version 3.1.0. `addClasspath` is set to `true` and `classpathPrefix` is set to `lib/`. `mainClass` is set to my app's main class. It works properly when I have no dependencies in my code, working only with my own classes. Sorry, I am a bit new to Maven so I am mostly poking here and there when it comes to POM. – NakedCat May 01 '18 at 18:53
  • Try opening the built jar and verify the dependent jars are included. And check the manifest classpath to make sure those jars are referenced. – Andrew S May 01 '18 at 19:04
  • @AndrewS it seems those jars are not included, I see only my classes, the Manifest file which is trying to access those dependencies and the pom file. – NakedCat May 01 '18 at 19:10

1 Answers1

0

bytedeco is missing so you should add org.bytedeco dependency in your pom.xml

<dependency>
    <groupId>org.bytedeco</groupId>
    <artifactId>javacv-platform</artifactId>
    <version>1.4.1</version>
  </dependency>
Azzabi Haythem
  • 2,318
  • 7
  • 26
  • 32