Home > OS >  Problem starting my application using JavaFX
Problem starting my application using JavaFX

Time:06-25

So i'm using IntelliJ and I built my application using JavaFX. But when i'm starting my main:

package fr.agglomistral.programme;

import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import fr.agglomistral.classedao.BusDAO;
import fr.agglomistral.classemetier.Bus;
import fr.agglomistral.outils.ConnexionMysql;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/fr/agglomistral/vues/Login.fxml"));
        primaryStage.setTitle("AggloMistral");
        primaryStage.setScene(new Scene(root,1680,1020));
        primaryStage.show();
        
        

    }

    public static void main(String[] args) {
        launch(args);
        BusDAO busDAO = new BusDAO();
        Bus bus = new Bus("MARQUE", "IMMAT", 12, 12);
        busDAO.create(bus);
        ConnexionMysql.disconnect();
    }

}

I get the following errors, and I don't get where those come from... Everything was working perfectly until I switched branches on github and had to set all the configurations all over again...

This is a picture of my configuration below: Running configuration

The errors I'm getting:

"C:\Program Files\Java\jdk-17.0.2\bin\java.exe" --module-path C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib --add-modules=javafx.controls "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.1\lib\idea_rt.jar=3220:C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\lilian.carion\Documents\Agglo-Mistral\classes\production\Agglo-Mistral;C:\Users\lilian.carion\Documents\mysql-connector-java-8.0.29\mysql-connector-java-8.0.29.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx-swt.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.web.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.base.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.fxml.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.media.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.swing.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.controls.jar;C:\Users\lilian.carion\Documents\javafx-sdk-18.0.1\lib\javafx.graphics.jar;C:\Users\lilian.carion\Downloads\javafx\javafx-swt.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.web.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.base.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.fxml.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.media.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.swing.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.controls.jar;C:\Users\lilian.carion\Downloads\javafx\javafx.graphics.jar;C:\Users\lilian.carion\Downloads\jsch-0.1.55.jar;C:\Users\lilian.carion\.m2\repository\junit\junit\4.13.1\junit-4.13.1.jar;C:\Users\lilian.carion\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\lilian.carion\.m2\repository\org\junit\jupiter\junit-jupiter\5.8.1\junit-jupiter-5.8.1.jar;C:\Users\lilian.carion\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.8.1\junit-jupiter-api-5.8.1.jar;C:\Users\lilian.carion\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\lilian.carion\.m2\repository\org\junit\platform\junit-platform-commons\1.8.1\junit-platform-commons-1.8.1.jar;C:\Users\lilian.carion\.m2\repository\org\apiguardian\apiguardian-api\1.1.2\apiguardian-api-1.1.2.jar;C:\Users\lilian.carion\.m2\repository\org\junit\jupiter\junit-jupiter-params\5.8.1\junit-jupiter-params-5.8.1.jar;C:\Users\lilian.carion\.m2\repository\org\junit\jupiter\junit-jupiter-engine\5.8.1\junit-jupiter-engine-5.8.1.jar;C:\Users\lilian.carion\.m2\repository\org\junit\platform\junit-platform-engine\1.8.1\junit-platform-engine-1.8.1.jar fr.agglomistral.programme.Main
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:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
    at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1071)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at [email protected]/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
    at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x7dff628f) 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 @0x7dff628f
    at com.sun.javafx.fxml.FXMLLoaderHelper.<clinit>(FXMLLoaderHelper.java:38)
    at javafx.fxml.FXMLLoader.<clinit>(FXMLLoader.java:2135)
    at fr.agglomistral.programme.Main.start(Main.java:22)
    at [email protected]/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at [email protected]/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at [email protected]/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at [email protected]/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at [email protected]/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    ... 1 more
Exception running application fr.agglomistral.programme.Main

Process finished with exit code 1

CodePudding user response:

I had similar issue. For me solution was to add following configuration :

--add-modules javafx.controls,javafx.fxml

insted of just

--add-modules javafx.controls
  • Related