내 코드는 성공적으로 컴파일되지만 실행되지 않습니다. 다음은 관련 코드입니다. "javac -cp :/Users/DavidOwens/javacv-bin/* ICGPixelGetter.java"로 컴파일하고 javacv-bin은 내 사용자 폴더에 있습니다.패키지와 일치하지 않는 .NoClassDefFoundError
//Takes a video file and gets frame grabs of it
private ArrayList<ImageView> getFrameGrabs() {
try{
//get video frames
FFmpegFrameGrabber g = new FFmpegFrameGrabber("for david.mpeg");
g.start();
for (int i = 1 ; i < 10 ; i++) {
ImageIO.write(g.grab().getBufferedImage(), "jpg",
new File("frame-dump/video-frame-"
+ System.currentTimeMillis() + ".png"));
}
g.stop();
}
catch(Exception ex){
System.out.println("Frame Grab IOException");
}
return frameGrabs;
}//END METHOD
및 주요 응용 프로그램의 시작은
import java.util.*;
import java.io.*;
import javax.imageio.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.input.*;
import javafx.scene.control.ContentDisplay;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.layout.BorderPane;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.text.*;
import javafx.scene.image.*;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import org.bytedeco.javacv.*;
import org.bytedeco.javacpp.*;
@Override //Override start method in Application class
public void start(Stage primaryStage) {
getFrameGrabs();
//bunch of code that works fine
}
나는이 스택 트레이스
Exception in Application start method
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/bytedeco/javacv/FFmpegFrameGrabber
at ICGPixelGetter.getFrameGrabs(ICGPixelGetter.java:112)
at ICGPixelGetter.start(ICGPixelGetter.java:57)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.ClassNotFoundException: org.bytedeco.javacv.FFmpegFrameGrabber
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 8 more
컴파일하는 방법과 관련이 없습니다. 그것은 당신이 ** 실행하는 ** ** 문제입니다. –
@JBNizet "java filename"과 함께 터미널을 통해 프로그램을 실행할 때이 오류가 발생합니다. 어떻게 다르게 실행할 것을 권장합니까? –
글쎄, 당신의 클래스는'.'에있는 클래스들과'. :/Users/DavidOwens/javacv-bin /'에있는 모든 jar에 의존합니다. 따라서, 컴파일 할 때와 마찬가지로, 현재 디렉토리와 jar는 classpath에 있어야한다 : java -cp : :/Users/DavidOwens/javacv-bin/* ICGPixelGetter'. 클래스를 기본 패키지 BTW에 넣는 것은 끔찍한 습관입니다. –