简体   繁体   中英

webcam problems with raspberry pi (java): ClassNotFoundException

we are struggling with getting control over a webcam in java on a raspberry. we try many ways and the one which seems to be the best is to use SarXos Webcam Capture API. So we add this to the project:

  • bridj-0.7-20140918.jar
  • webcam-capture-0.3.12-20161206.184756-3.jar

then we try a test (the following code) but it send an error message. Please we need your help :)

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

/**
 * Example of how to take single picture.
 * 
 * @author Bartosz Firyn (SarXos)
 */
public class webcam {

    public static void main(String[] args) throws IOException {

        // get default webcam and open it
        Webcam webcam1 = Webcam.getDefault();
        webcam1.open();

        // get image
        BufferedImage image = webcam1.getImage();

        // save image to PNG file
        ImageIO.write(image, "PNG", new File("test.png"));
    }
}

our error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory   
    at com.github.sarxos.webcam.Webcam.<clinit>(Webcam.java:101)
    at webcam.main(webcam.java:21)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 2 more

you need to add slf4j-api-1.7.25.jar and slf4j-simple-1.7.25.jar file into your class path. you can download from below link and put into your lib directory and add into your java build path .

1) slf4j-api-1.7.25.jar click here

2)slf4j-simple-1.7.25.jar click here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM