每当我尝试打开JFoenix程序时,控制台中就会出现相同的错误消息...
当我使用标准JavaFx组件时,一切正常
关于Java的信息,我使用:
我已经将JFoenix库导入了eclipse。
我使用jdk1.8.0_111;
我有最新的JFoenix jar
那是错误:
Exception in Application start method
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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
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.UnsupportedClassVersionError: com/jfoenix/controls/JFXButton has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
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)
at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:2916)
at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:2905)
at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2846)
at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2692)
at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2661)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2517)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at application.Main.start(Main.java:26)
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)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more
Exception running application application.Main
我的主类:
package application;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
private AnchorPane root;
private Stage primaryStage;
@Override
public void start(Stage primaryStage) {
try {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("SimpleMySQLConnector - Login");
FXMLLoader load;
load = new FXMLLoader(getClass().getResource("/application/LoginScreen.fxml"));
root = load.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
package application;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
public class Main extends Application {
private AnchorPane root;
private Stage primaryStage;
@Override
public void start(Stage primaryStage) {
try {
this.primaryStage = primaryStage;
this.primaryStage.setTitle("SimpleMySQLConnector - Login");
FXMLLoader load;
load = new FXMLLoader(getClass().getResource("/application/LoginScreen.fxml"));
root = load.load();
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
那是fxml文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXCheckBox?>
<?import com.jfoenix.controls.JFXPasswordField?>
<?import com.jfoenix.controls.JFXTextField?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.paint.LinearGradient?>
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.text.Font?>
<AnchorPane prefHeight="700.0" prefWidth="1118.0" style="-fx-background-color: #000000;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<AnchorPane layoutX="587.0" layoutY="55.0" prefHeight="590.0" prefWidth="500.0" style="-fx-background-color: #0a52c9;">
<children>
<JFXTextField focusColor="#fafafa" layoutX="109.0" layoutY="156.0" prefHeight="42.0" prefWidth="282.0" promptText="Benutzername" unFocusColor="#3fd6f4">
<font>
<Font name="Arial" size="18.0" />
</font>
</JFXTextField>
<JFXPasswordField focusColor="WHITE" layoutX="112.0" layoutY="279.0" prefHeight="42.0" prefWidth="282.0" promptText="Passwort" unFocusColor="#3fd6f4">
<font>
<Font size="18.0" />
</font>
</JFXPasswordField>
<JFXButton layoutX="204.0" layoutY="375.0" prefHeight="42.0" prefWidth="91.0" style="-fx-background-color: #3fd6f4;" text="Login" textFill="WHITE">
<font>
<Font name="Arial" size="18.0" />
</font>
</JFXButton>
<JFXCheckBox layoutX="159.0" layoutY="479.0" text="Angemeldet bleiben" textFill="WHITE">
<font>
<Font name="Arial" size="18.0" />
</font>
</JFXCheckBox>
<Label layoutX="188.0" layoutY="58.0" text="Login">
<font>
<Font name="Arial" size="50.0" />
</font>
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
<Stop color="#3fd6f4" />
<Stop color="WHITE" offset="1.0" />
</stops>
</LinearGradient>
</textFill>
</Label>
</children>
</AnchorPane>
<Label layoutX="28.0" layoutY="44.0" prefHeight="198.0" prefWidth="582.0" text="Willkommen bei" textAlignment="CENTER">
<font>
<Font name="Arial" size="30.0" />
</font>
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
<Stop color="#00eade" />
<Stop color="WHITE" offset="1.0" />
</stops>
</LinearGradient>
</textFill>
</Label>
<Label layoutX="28.0" layoutY="183.0" text="SimpleMySQLConnector">
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
<Stop color="#02dbea" />
<Stop color="WHITE" offset="1.0" />
</stops>
</LinearGradient>
</textFill>
<font>
<Font size="40.0" />
</font>
</Label>
</children>
</AnchorPane>
希望您能为我提供这些信息
最佳答案
尝试将您的jdk升级到jdk 9版本。