经过数小时的测试,我仍然无法将我的 JavaFX 项目作为本机应用程序(Windows 上的 .exe)运行。我使用 JavaFX 11.0.2。执行时我没有收到任何错误mvn clean gluonfx:build
。错误伴随着mvn gluonfx:nativerun
:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Sep 02, 2021 12:13:03 AM com.sun.javafx.application.PlatformImpl startup
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @4a163575'
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] javafx.fxml.LoadException:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] fr/bullobily/fxml/Main.fxml:134
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB]
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.init(FxWindow.java:140)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<init>(FxWindow.java:116)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<clinit>(FxWindow.java:104)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.ChatApp.start(ChatApp.java:44)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java
:0)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:179)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.lang.Thread.run(Thread.java:829)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Caused by: java.lang.UnsupportedOperationException: Cannot determine type for property.
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.getSetterMethod(BeanAdapter.java:178)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:251)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:54)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.set(FXMLLoader.java:193)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:801)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] ... 20 more
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] javafx.fxml.LoadException:
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] fr/bullobily/fxml/Chat.fxml:20
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB]
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2685)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.init(FxWindow.java:140)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<init>(FxWindow.java:116)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.model.FxWindow.<clinit>(FxWindow.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.invokeClassInitializer(ClassInitializationInfo.java:375)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.classinitialization.ClassInitializationInfo.initialize(ClassInitializationInfo.java:295)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at fr.bullobily.ChatApp.start(ChatApp.java:44)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.security.AccessController.doPrivileged(AccessController.java:105)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_VA_LIST:Ljava_lang_Runnable_2_0002erun_00028_00029V(JNIJavaCallWrappers.java
:0)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication._runLoop(WinApplication.java)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:179)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at java.lang.Thread.run(Thread.java:829)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at com.oracle.svm.core.windows.WindowsJavaThreads.osThreadStartRoutine(WindowsJavaThreads.java:138)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] Caused by: com.sun.javafx.fxml.PropertyNotFoundException: Property "cacheShape" does not exist or is read-only.
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processValue(FXMLLoader.java:358)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processPropertyAttribute(FXMLLoader.java:335)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$Element.processInstancePropertyAttributes(FXMLLoader.java:245)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:778)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2924)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2639)
[jeu. sept. 02 00:13:03 CEST 2021][INFOS] [SUB] ... 20 more
这是我的 Main.fxml 和 Chat.fxml(使用 Scene Builder 创建):
主要.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.geometry.Rectangle2D?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.paint.Color?>
<?import javafx.scene.paint.LinearGradient?>
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.text.Font?>
<Scene xmlns="%javafx.fx" xmlns:fx="%javafx.fxml" fx:controller="fr.bullobily.controller.MainController">
<AnchorPane prefHeight="387.0" prefWidth="559.0">
<children>
<HBox layoutX="274.0" layoutY="120.0" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
<VBox minWidth="-Infinity" prefHeight="387.0" prefWidth="211.0" style="-fx-background-color: #1DB6B1;" stylesheets="@../css/Main.css" HBox.hgrow="NEVER">
<children>
<Pane prefHeight="91.0" prefWidth="170.0">
<children>
<ImageView fitHeight="50.0" fitWidth="50.0" layoutY="18.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/app_icon.png" />
</image>
</ImageView>
<Label layoutX="56.0" prefHeight="86.0" prefWidth="111.0" text="Ma super appli de chat" wrapText="true">
<font>
<Font name="Candara Light" size="19.0" />
</font>
<textFill>
<LinearGradient endX="1.0" endY="1.0">
<stops>
<Stop>
<color>
<Color red="0.8526315689086914" green="0.028421051800251007" blue="0.028421051800251007" />
</color>
</Stop>
<Stop offset="1.0">
<color>
<Color green="0.03805406019091606" blue="1.0" />
</color>
</Stop>
</stops>
</LinearGradient>
</textFill>
</Label>
</children>
</Pane>
<VBox prefHeight="149.0" prefWidth="213.0">
<children>
<GridPane>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="132.79999542236328" minWidth="10.0" prefWidth="119.40001220703125" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="101.59999542236329" minWidth="10.0" prefWidth="71.39998779296876" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<Label prefWidth="114.0" text="Nom d'utilisateur :" />
<Label text="Personnes en ligne :" GridPane.rowIndex="1" />
<Label fx:id="usernameLab" text="Label" GridPane.columnIndex="1" />
<Label fx:id="onlineUsersCount" prefWidth="28.0" text="Label" GridPane.columnIndex="1" GridPane.rowIndex="1" />
</children>
</GridPane>
<Button mnemonicParsing="false" onAction="#onConnectButton" prefWidth="1000.0" text="Connexion">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/connection.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
<padding>
<Insets bottom="20.0" top="20.0" />
</padding>
</VBox>
<VBox fx:id="buttonsVbox" prefHeight="0.0" prefWidth="170.0" spacing="20.0">
<children>
<Button mnemonicParsing="false" onAction="#onButtonChat" prefWidth="1000.0" text="Chat" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets />
</VBox.margin>
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/chat.png" />
</image>
<viewport>
<Rectangle2D />
</viewport>
</ImageView>
</graphic>
</Button>
<Button mnemonicParsing="false" onAction="#onButtonParameters" prefWidth="1000.0" text="Paramètres">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../pictures/picture.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
<VBox.margin>
<Insets bottom="20.0" />
</VBox.margin>
<padding>
<Insets bottom="20.0" top="20.0" />
</padding>
</VBox>
</children>
<padding>
<Insets left="10.0" right="10.0" />
</padding>
</VBox>
<AnchorPane fx:id="contentPane" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</AnchorPane>
</Scene>
聊天.fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" cacheShape="false" centerShape="false" nodeOrientation="RIGHT_TO_LEFT" prefHeight="306.0"
prefWidth="329.0" scaleShape="false" spacing="21.0" xmlns="%javafx.fx" xmlns:fx="%javafx.fxml"
fx:controller="fr.bullobily.controller.ChatController">
<padding>
<Insets bottom="30.0" left="30.0" right="30.0" top="30.0"/>
</padding>
<ListView fx:id="chatList" prefHeight="530.0" prefWidth="539.0"/>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="8.0">
<TextField fx:id="textSelectionField" prefWidth="539.0"/>
<Button mnemonicParsing="false" onAction="#sendToChat" text="Envoyer"/>
</VBox>
</VBox>
最后是我的src/main/resources/META-INF/substrate/config/reflectionconfig.json
,它(应该)包含我在我的 fxml 文件中使用的所有类和方法:https ://pastebin.com/EqQpBiKH
我的代码在 IntelliJ 中运行时运行良好,但不是从本机映像运行。我用尽了我想象的所有解决方案的可能性……