0

I am getting the following error when I run the main file in the Javafx project:

C:\Users\monu\OneDrive\Documents\jdk-11.0.10\bin\java.exe --module-path C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib --add-modules javafx.fxml,javafx.controls,javafx.graphics --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 2020.2.3\lib\idea_rt.jar=59212:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2.3\bin" -Dfile.encoding=UTF-8 -classpath C:\D-drive\codage-aider\student\agbi\sample-github\C195\out\production\C195;C:\D-drive\libraries\mysql-connector-java-8.0.26.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx-swt.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.web.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.base.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.fxml.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.media.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.swing.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.controls.jar;C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib\javafx.graphics.jar main.java.C195
Graphics Device initialization failed for :  d3d, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:254)
    at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:264)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics/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:62)
    at 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: Error initializing QuantumRenderer: no suitable pipeline found
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.base/java.lang.Thread.run(Thread.java:834)
Exception in thread "main" 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)
    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: No toolkit found
    at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:276)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    ... 5 more

Process finished with exit code 1

In the run configurations in Intellij Idea the following is specified for the value of VM arguments : `--module-path "C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib" --add-modules javafx.fxml,javafx.controls,javafx.graphics`

I have included the necessary JavaFX lib folder and MySQL connector jar that I am using in my project, But strangely I still get this weird error.
I downloaded the SDK for windows from here https://gluonhq.com/products/javafx/ that's a little weird. I am not sure if I am missing anything. As I have followed all the steps from the JavaFX website. I am using a non-maven project here. Any ideas or hints on how
to proceed to debug this or fix it? Thanks



Minimal reproducible example :

 package sample;

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

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
    }


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

sample.fxml :

<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<GridPane fx:controller="sample.Controller"
          xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
</GridPane>


The VM arguments in the Intellij is - --module-path "C:\D-drive\libraries\javafx-sdk-17.0.0.1\lib" --add-modules javafx.controls


This is a simple normal JavaFX program. There is some setup issue that is causing the problem because there cannot be a simpler program than this. It looks like no JavaFX project is working.
I am experimenting with non-maven projects only.
Monu Didi
  • 7
  • 4
  • I tried working with a simple JavaFX project. Strangely that also gave the same error. So here is the minimal reproducible example. One will have to provide the proper path for JavaFX SDK, though. https://ufile.io/w0z68i2g This is just a hello world project, and it errors out. Looks like some setup issue at my end. – Monu Didi Oct 03 '21 at 14:37
  • As you are using idea, I recommend that you create a new [javafx project](https://www.jetbrains.com/help/idea/javafx.html) using that and see if it works in your environment. – jewelsea Oct 04 '21 at 01:53
  • Edit the question, put everything for the [mcve] in the question not an offsite link to a zip. – jewelsea Oct 04 '21 at 02:18
  • @jewelsea, I created a JavaFX project only. I will share a minimal reproducible example – Monu Didi Oct 04 '21 at 09:16
  • something wrong in the setup .. not much more to say from afar ;) Start with an example that's guaranteed to work (see f.i. https://stackoverflow.com/questions/52467561/intellij-cant-recognize-javafx-11-with-openjdk-11), tweak your context until that's working. Only after that's the case, move forward :) – kleopatra Oct 04 '21 at 09:40

1 Answers1

0

i have never worked with intellij, i work with eclipse, i had the same problem not while running from the ide but when i exported it as a jar. The thing is, the javafx sdk has a bin folder that contains several dll files, important for running the javafx app. The ide should use them once you add the libs to the build path, at least eclipse does that, make sure you have maintained the original folders in the sdk To avoid this kind of problems in the future, and avoid to manually add all the dlls when i export the jar, i created a new java runtime image, using jlink, that has all the javafx sdk built in it. This is the best option at least for me, if you want to go this way, you should download the javafx jmods and add them to the jmods folder in the jdk installation, after that you can create a new runtime image with jlink I'll edit this post later and add the jlink command line

Hamlet
  • 307
  • 1
  • 8