我对 Java 应用程序还很陌生。我正在尝试在 Eclipse 中运行这个开源应用程序。我已经一一包含了所有需要的外部库并删除了所有错误。现在,当我运行应用程序时,我在运行时遇到异常。控制台中的消息如下:
Exception in thread "JavaFX Application Thread" Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:189)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:112)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:105)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:235)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:208)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:221)
at com.shootoff.Main.<clinit>(Main.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$2(LauncherImpl.java:352)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.joran.spi.JoranException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 18 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.NullPointerException
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
现在,据我所知,异常是关于 slf4j 日志库的。我尝试在“配置构建路径”的外部 jar 部分中包含不同版本的 slf4j,但我得到了相同的异常。所以我认为 slf4j 的版本控制不是这里的问题。另外,在异常中,我可以看到异常发生在以下行中:
private static final Logger logger = LoggerFactory.getLogger(Main.class);
除此之外,我对下一步该做什么一无所知。
我已将相关代码粘贴在下面。希望它有助于解决问题。 谢谢。
package com.shootoff;
import com.shootoff.camera.CameraFactory;
import com.shootoff.camera.cameratypes.OptiTrackCamera;
import com.shootoff.camera.cameratypes.PS3EyeCamera;
import com.shootoff.config.Configuration;
import com.shootoff.config.ConfigurationException;
import com.shootoff.gui.controller.ShootOFFController;
import com.shootoff.headless.HeadlessController;
import com.shootoff.plugins.TextToSpeech;
import com.shootoff.util.HardwareData;
import com.shootoff.util.SystemInfo;
import com.sun.javafx.application.LauncherImpl;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.file.Files;
import java.util.Enumeration;
import java.util.Optional;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Modality;
import javafx.stage.Stage;
import nu.pattern.OpenCV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Main extends Application {
private static final Logger logger = LoggerFactory.getLogger(Main.class);
private static final int MINIMUM_CPU_SCORE_EXCELLENT = 4000;
private static final int MINIMUM_CPU_SCORE_PASSABLE = 3000;
private static final long MINIMUM_RAM_EXCELLENT = 11712L;
private static final long MINIMUM_RAM_PASSABLE = 4096L;
private static final String POOR_HARDWARE_MESSAGE = "Hardware Status: Poor -- Based on the data we gathered,\nMATS will likely not run well on this machine.";
private static final String PASSABLE_HARDWARE_MESSAGE = "Hardware Status: Passable -- Based on the data we gathered,\nMATS will likely run OK on this machine but may miss\noccasional shots.";
private static final String EXCELLENT_HARDWARE_MESSAGE = "Hardware Status: Excellent -- Based on the data we gathered,\nthis machine should have no problems running MATS.";
public static final String SHOOTOFF_DOMAIN = "http://shootoffapp.com/";
private boolean isJWS = false;
private static final String RESOURCES_METADATA_NAME = "shootoff-writable-resources.xml";
private static final String RESOURCES_JAR_NAME = "shootoff-writable-resources.jar";
private File resourcesMetadataFile;
private File resourcesJARFile;
private Stage primaryStage;
private static final String VERSION_METADATA_NAME = "shootoff-version.xml";
private static Optional<String> version = Optional.empty();
private static boolean shouldShowV4lWarning = false;
public static final String SPLASH_IMAGE = "http://fxexperience.com/wp-content/uploads/2010/06/logo.png";
private static final int SPLASH_WIDTH = 676;
private static final int SPLASH_HEIGHT = 227;
最佳答案
SLF4J 似乎不是这里的问题。你缺少的是一个 logback jar。 阅读此处的文档 http://logback.qos.ch/查看您需要哪个库。
关于java - 关于 SLF4J 的异常(exception)情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58834295/