-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"));
}
}
我寫了這個Java代碼來捕獲通過網絡攝像頭的照片,但是這個代碼是拋出一個錯誤/異常,請告訴我該怎麼解決它。?異常在線程「主要」 java.lang.NoClassDefFoundError:組織/ SLF4J /的LoggerFactory
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
把Slf4j jar放到你的類路徑中... http://stackoverflow.com/questions/13434862/xuggle-error-exception-in-thread-main-java-lang-noclassdeffounderror-org-slf – 2015-02-08 22:46:20
possible [ClassNotFoundException:org.slf4j.LoggerFactory]的副本(http://stackoverflow.com/questions/9030065/classnotfoundexception-org-slf4j-loggerfactory) – flo 2015-02-08 22:53:27