-2
package photo;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import com.github.sarxos.webcam.Webcam;

public class capture {

    public static void main(String arg[]) throws IOException {
        Webcam webcam = Webcam.getDefault();
        webcam.open();
        BufferedImage image = webcam.getImage();
        ImageIO.write(image, "JPG", new File("test.jpg"));
    }

}

I have written this java code to capture photo through webcam, but this code is throwing an error/exception please tell how can I fix it.?

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.github.sarxos.webcam.Webcam.<clinit>(Webcam.java:97)
    at photo.capture.main(capture.java:12)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 2 more
  • Put Slf4j jar on your class path...duplicate of http://stackoverflow.com/questions/13434862/xuggle-error-exception-in-thread-main-java-lang-noclassdeffounderror-org-slf – Jayaram Feb 08 '15 at 22:46
  • possible duplicate of [ClassNotFoundException: org.slf4j.LoggerFactory](http://stackoverflow.com/questions/9030065/classnotfoundexception-org-slf4j-loggerfactory) – flo Feb 08 '15 at 22:53

1 Answers1

1

Download SLF4J and put the slf4j-api-1.7.2.jar file onto your class path.

Ankur Piyush
  • 308
  • 1
  • 9