V
V
Virgil Merkel2019-03-21 21:41:50
Java
Virgil Merkel, 2019-03-21 21:41:50

Error when building FXML in Java, how to fix it?

there is a formfx program that should open formParta.fxml
formParta:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>


<VBox alignment="TOP_CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <TextField id="login" alignment="CENTER" promptText="Логин">
         <VBox.margin>
            <Insets top="60.0" />
         </VBox.margin>
      </TextField>
      <PasswordField id="password" alignment="CENTER" promptText="Пароль">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </PasswordField>
      <TextField id="userid" alignment="CENTER" prefHeight="0.0" prefWidth="503.0" promptText="user id">
         <VBox.margin>
            <Insets top="40.0" />
         </VBox.margin>
      </TextField>
      <ChoiceBox id="message" prefHeight="25.0" prefWidth="339.0">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </ChoiceBox>
      <Button id="sendbutton" mnemonicParsing="false" prefHeight="25.0" prefWidth="85.0" text="Отправить">
         <VBox.margin>
            <Insets top="10.0" />
         </VBox.margin>
      </Button>
   </children>
</VBox>

formfx:
package deleveryClub;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;



public class formfx extends Application{
    public static void main(String[] args){
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        Group group = new Group();
        Parent content = FXMLLoader.load(getClass().getResource("formParta.fxml"));
        BorderPane root = new BorderPane();
        root.setCenter(content);
        group.getChildren().add(root);

        //primaryStage.setTitle("Parta");
        primaryStage.setScene(new Scene(group, 400, 400));
        primaryStage.show();
    }
}

gives an error message:
"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.5\lib\idea_rt.jar=5378:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.3.5\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\blurryface\IdeaProjects\first_project\target\classes;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-fxml\12\javafx-fxml-12.jar;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-fxml\12\javafx-fxml-12-win.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-java\3.141.59\selenium-java-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\3.141.59\selenium-chrome-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\3.141.59\selenium-edge-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\3.141.59\selenium-opera-driver-3.141.59.jar;C:\Users\blurryface\.m2\repository\org\openjfx\javafx-graphics\11\javafx-graphics-11.jar;
Exception in Application start method
java.lang.reflect.InvocationTargetException
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
  at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
  at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
  at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x32224179) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.util to unnamed module @0x32224179
javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
  at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
  at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
  ... 1 more
Exception running application deleveryClub.formfx

Process finished with exit code 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2019-03-22
@zolt85

Stacktrace is sometimes useful to read.
Add the line to the application launch options

--add-exports=javafx.graphics/com.sun.javafx.util=ALL-UNNAMED

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question