auszuführen Wenn ich versuche, Java zu tun -jar app.jar ich dieses:Fehler java.lang.ClassNotFoundException: org.slf4j.LoggerFactory bei dem Versuch, das Glas
Exception in thread "JavaFX Application Thread" Exception in thread "main"
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at tao.qaflash.GUI.<clinit>(GUI.java:14)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplicationWithArgs$156(LauncherImpl.java:352)
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)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 12 more
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.NullPointerException
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:383)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
... 5 more
Meine Umgebung ist: Java 1.8. 0_92, Gradel 2.16, Eclipse Mars 4.5.0, Java FX. Auch ich habe diesen Fehler gegoogelt und ich habe alles von dort aus versucht, aber ohne Erfolg. Ich habe versucht, zu den build.gradle als Abhängigkeiten slfj-einfach, log4j, logback-classic, slf4j-jdk14, junit, vaadin-slf4j-jdk14 hinzufügen, aber der Fehler immer wieder angezeigt.
Wenn ich die Anwendung von Eclipse ausführen, alles funktioniert gut, die Protokolle geschrieben werden, nur wenn ich versuche, das Glas aus der Befehlszeile auszuführen, bekomme ich diese ClassNotFoundException.
build.gradle wie folgt aussieht:
dependencies {
compile 'net.sf.staf:jstaf:3.4.4'
// SLF4J API module which will be used for logging
compile 'org.slf4j:slf4j-api:1.7.21'
// Log4J2 logging framework including the binding module to slf4j
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.5'
compile 'org.apache.logging.log4j:log4j-api:2.5'
compile 'org.apache.logging.log4j:log4j-core:2.5'
testCompile 'junit:junit:4.12'
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"
}
Jede Hilfe greately geschätzt wird.
Ich schätze das schnelle Comeback :-) – GhostCat
Für alle anderen lesen: Führen Sie Ihre Datei.jar mit der gleichen JDK-Version, wie Sie es kompiliert? (Als ersten Schritt empfehle ich dasselbe JDK zu verwenden, nicht einmal JRE derselben Version.) Nur um mögliche Fehlerquellen auszuschließen. Dies behebt mein Problem mit den gleichen Symptomen :) Verwenden Sie diese Beispielzeile, um auf eine beliebige JVM zu zeigen: "c: \ Programme \ Java \ jdk1.8.0_121 \ bin \ java.exe" -jar d: \ Path \ To \ Your \ File.jar –