-
Notifications
You must be signed in to change notification settings - Fork 1.1k
How to solve java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
Bartosz Firyn edited this page Mar 16, 2017
·
2 revisions
The error is:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.github.sarxos.webcam.Webcam.<clinit>(Webcam.java:38)
at capturador.Capturador.main(Capturador.java:27)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more
This is because SLF4J jar file needs to be added into your application's classpath. SLF4J is required by Webcam Capture API for logging purpose.
Where to find SLF4J jar? You can either:
- The best is to download latest stable ZIP file with Webcam Capture API (you will find link on the project main page in Download section) and take required JARs from
libs
directory of this ZIP, or - Download required JARs from Maven Central (but you have to make sure to find the appropriate version), or
- Build your project with Maven.