2

I'm trying to get JavaFX to work on windows 10 with a non-modular project. I have Java version 14.0.1 and JavaFX version 15.0.1. I followed the instructions listed here exactly, but when I run the program it gives me this error:

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:280)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:244)
    at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:261)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    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:564)
    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:94)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
    at java.base/java.lang.Thread.run(Thread.java:832)
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:564)
    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:273)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:658)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
    ... 5 more

I've also looked at these questions(1, 2, 3), and I did what they said but I still get an error when I run it. I downloaded the JavaFX sdk file from the official download website, and my VM options are:

--module-path "C:\Program Files\Java\javafx-sdk-15.0.1\lib" --add-modules=javafx.controls,javafx.fxml 

I've tried changing the module path to a path in a different location as well as a path with no spaces to no avail. I've also tried using Eclipse, Netbeans, and no IDE (all setup instructions were from the official website), but none of them work. The program which I'm trying to run is a just a test program.

package sample;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            // create a new Text shape
            Text messageText = new Text("Hello World! Lets learn JavaFX.");

            // stack page
            StackPane root = new StackPane();

            // add Text shape to Stack Pane
            root.getChildren().add(messageText);

            Scene scene = new Scene(root,400,400);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }

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

EDIT: Response to the answer

Sorry for the late reply, but I tried to put what you said in the VM options, which I think is what you mean, but I got an error

Error: Could not find or load main class run.jvmargs=--module-path
Caused by: java.lang.ClassNotFoundException: run.jvmargs=--module-path.

I also tried running it without the run.jvmargs= but it also doesn't work. I got the below error.

Error: Could not find or load main class \
Caused by: java.lang.ClassNotFoundException: \

By the way the specific VM options that I have are below.

run.jvmargs=--module-path "C:\\Program Files\\Java\\javafx-sdk-15.0.1\\lib" \
    --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \
    --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED \
    --add-exports=javafx.web/com.sun.webkit.network=ALL-UNNAMED \
    --add-exports=javafx.web/com.sun.webkit.dom=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.scenario.animation.shared=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.javafx.tk.quantum=ALL-UNNAMED

EDIT - 2: file structures on the right

yakatoi
  • 37
  • 8

1 Answers1

0

my project also uses this run.jvmargs property. HTere's

run.jvmargs=--module-path "D:\\Libraries\\Java9\\openjfx-13.0.2_windows-x64_bin-sdk\\javafx-sdk-13.0.2\\lib" \
    --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \
    --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED \
    --add-exports=javafx.web/com.sun.webkit.network=ALL-UNNAMED \
    --add-exports=javafx.web/com.sun.webkit.dom=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.scenario.animation.shared=ALL-UNNAMED \
    --add-exports=javafx.graphics/com.sun.javafx.tk.quantum=ALL-UNNAMED // <<-- notice this thing

also, make sure you're using \\ instead of \

EverNight
  • 964
  • 7
  • 16
  • Hey, thanks for the reply. Unfortunately, I still have an error with your VM options. I have the details edited at the bottom of my questions. If you don't mind, could you please take a look at that? – yakatoi Mar 07 '21 at 04:56
  • hi, @yakatoi , there is another parameter in that file called `main.class` i think you should set it to `sample.Main` to correspond with the Application class you're using to start the project. as a verifier, you should use `this.getClass().getName()` to get that string. – EverNight Mar 08 '21 at 08:42
  • thanks for the response! I'm a bit confused by what you mean. Are you talking about the package name in the program or the file structure of the project? If it's about the file structure, I have a pic of it in the question. If its about the package name, I changed it from sample to sample.main. but nothing happened. – yakatoi Mar 08 '21 at 22:18
  • Update! I kinda fixed the problem, not really. I just switched to Java SE 8 cuz I'm fairly kind of maybe sure the project I'm working on works with SE8. Kind of a temp solution, but it works. Thanks for all the help tho! – yakatoi Mar 09 '21 at 03:40
  • right, so java uses packages. these are relatively similar to folder structures. if you have a folder `X` inside folder `A`, with Class `C` in it, it will be `X.A.C` ... `X` and `A` are `packages`. When you compile/run a program, the classpath compiler uses folder structures to establish paths to classes... so it will define it's `X.A.C` path for instantiating class C. Since you're using Class C to run the application ... you'll need the `X.A.C` reference set up as `main.class` in the `project.properties` file – EverNight Mar 09 '21 at 07:45
  • maybe i'm overcomplicating things... think of it like breadcrumbs... the package.class aka `x.a.c` example above is basically the route to your class. If you're using a main class to start your application, you need that route. You can easily get this route by adding temporary code somewhere, with `System.out.printline(this.getClass().getName());` and copy the resulting string in the `main.class` property of the `project.properties` file in which you've added `--add-modules` stuff – EverNight Mar 09 '21 at 07:52
  • it should go without saying that you should paste that system.out line in the class you want to set as the main class, and not some other one. – EverNight Mar 09 '21 at 07:53