Java FX .jar приложение не запускается

179
03 ноября 2019, 15:50

Здраствуйте, написал javafx приложение, в idea прекрасно компилится, но когда формирую executable jar, не запускается. При запуске через консоль видает следующее:

C:\Users\__it>java -jar "C:\Users\__it\Desktop\Ilab API UI + CODE v 2.0\ApplicationExampleForClients V_1.0 (CODE)\out\artifacts\ApplicationExampleForClients_V_1_0_jar\ApplicationExampleForClients V_1.0.jar"
Exception in Application start method
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 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(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.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
        at java.lang.Thread.run(Unknown Source)
Caused by: javafx.fxml.LoadException:
file:/C:/Users/__it/Desktop/Ilab%20API%20UI%20+%20CODE%20v%202.0/ApplicationExampleForClients%20V_1.0%20(CODE)/out/artifacts/ApplicationExampleForClients_V_1_0_jar/ApplicationExampleForClients%20V_1.0.jar!/Interface.fxml
        at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2543)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
        at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
        at Main.start(Main.java:27)
        at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
        at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
        at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(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$147(WinApplication.java:177)
        ... 1 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[56,1]
Message: Stream closed
        at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
        at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2513)
        ... 17 more
Exception running application Main

В чем беда подскажите пожалуйста Вот мой Main class:

public class Main extends Application {

public static void main(String[] args) throws Exception {
  launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
    Parent parent = FXMLLoader.load(getClass().getResource("Interface.fxml"));
   Scene scene = new Scene(parent);

    primaryStage.setScene(scene);
    primaryStage.setTitle("iLab Java API Tester");
    primaryStage.show();

}

}

[Декомпилений jar] []1

Вот FXML:

    <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<VBox fx:id="Rootes" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="1010.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="Control.Controller">
   <children>
      <Pane prefHeight="200.0" prefWidth="200.0">
         <children>
            <Label layoutX="349.0" layoutY="68.0" text="INPUT THE USER DATA" textAlignment="CENTER" textOverrun="WORD_ELLIPSIS">
               <font>
                  <Font size="31.0" />
               </font>
            </Label>
         </children>
      </Pane>
      <Pane prefHeight="320.0" prefWidth="1051.0">
         <children>
            <PasswordField fx:id="Password" layoutX="200.0" layoutY="67.0" prefHeight="39.0" prefWidth="336.0" />
            <Label layoutX="78.0" layoutY="69.0" text="Password">
               <font>
                  <Font size="25.0" />
               </font>
            </Label>
            <TextField fx:id="Host" layoutX="200.0" layoutY="124.0" prefHeight="39.0" prefWidth="336.0" />
            <TextField fx:id="Port" layoutX="200.0" layoutY="177.0" prefHeight="39.0" prefWidth="336.0" />
            <TextField fx:id="UserName" layoutX="200.0" layoutY="14.0" prefHeight="39.0" prefWidth="336.0" />
            <Label layoutX="130.0" layoutY="126.0" text="Host">
               <font>
                  <Font size="24.0" />
               </font>
            </Label>
            <Label layoutX="132.0" layoutY="179.0" text="Port">
               <font>
                  <Font size="25.0" />
               </font>
            </Label>
            <Label layoutX="59.0" layoutY="16.0" text="User Name">
               <font>
                  <Font size="25.0" />
               </font>
            </Label>
            <TextArea fx:id="Out" layoutX="547.0" layoutY="8.0" prefHeight="394.0" prefWidth="451.0" wrapText="true" />
         </children>
      </Pane>
      <Pane prefHeight="149.0" prefWidth="1080.0">
         <children>
            <Button fx:id="Autent" layoutX="332.0" layoutY="39.0" mnemonicParsing="false" onAction="#Autentification" text="AUTORIZATION" />
         </children>
      </Pane>
   </children>
</VBox>
Answer 1

До конца так и не разобрался в чем проблема, пути прописани относительно проекта, но помогло создать новый fxml и подключить его вместо старого, тогда все работает

READ ALSO
ArrayList &lt;ArrayList &lt;Integer&gt;&gt;

ArrayList <ArrayList <Integer>>

Как правильно добавлять элементы к списку типа

156
Как проинициализировать объекты enum вне класса

Как проинициализировать объекты enum вне класса

1Почему в конструктор объекта Enum нельзя передать значение позже (не в самом классе где он автоматически создается)?

167
Упростить код создания массивов

Упростить код создания массивов

Поскажите пожалуйста, можно ли упростить такой код? Или так и писать на 20 Case?

178
JFrame и JPanel в JAVA. не все отрисовываются

JFrame и JPanel в JAVA. не все отрисовываются

мое задание - написать имитацию тараканьих бегову меня есть такие классы: Game - основной класс, создает JFrame и принимает входной параметр (количество...

170