-2

I built a JavaFX application, which work on Windows and Linux, but not on Macs.

I tried the application with two Macs, and both have an M chip.

This is the error which I get:

Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at javafx.graphics@19.0.2/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
    at javafx.graphics@19.0.2/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
    at javafx.graphics@19.0.2/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:268)
    at javafx.graphics@19.0.2/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics@19.0.2/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
    at javafx.graphics@19.0.2/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
    at javafx.graphics@19.0.2/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.base/java.lang.Thread.run(Thread.java:1589)
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1081)
Caused by: java.lang.RuntimeException: No toolkit found
    at javafx.graphics@19.0.2/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:280)
    at javafx.graphics@19.0.2/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics@19.0.2/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics@19.0.2/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    ... 2 more`

This is my pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>...</groupId>
  <artifactId>...</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>...</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit.version>5.9.1</junit.version>
    <javafx.version>20-ea+4</javafx.version>
    <java.version>19.0.2</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.jdom</groupId>
      <artifactId>jdom2</artifactId>
      <version>2.0.5</version>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>19.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>19.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>19.0.2</version>
      <classifier>win</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>19.0.2</version>
      <classifier>linux</classifier>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>${javafx.version}</version>
      <classifier>mac</classifier>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>${javafx.version}</version>
      <classifier>mac</classifier>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>${javafx.version}</version>
      <classifier>mac-aarch64</classifier>
    </dependency>

    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>19.0.2</version>
      <classifier>mac</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>19.0.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-media</artifactId>
      <version>19.0.2</version>
    </dependency>

  </dependencies>

  <build>
    <plugins>
 ...

    </plugins>
  </build>
</project>

What I do make false?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    This might be helpful: https://stackoverflow.com/questions/57544721/cannot-execute-javafx-sample-on-macos-no-toolkit-found – SpaceTrucker Apr 19 '23 at 20:19
  • Verify that you installed the correct version for your Mac. – trashgod Apr 19 '23 at 22:25
  • I don't understand why you put `...` in the build plugins section to leave out important relevant info on what you are doing. – jewelsea Apr 20 '23 at 01:50
  • If you are building a cross-platform jar using [maven shade](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing) or something similar (unsupported configuration), then *all* javafx dependencies (including transitive ones), should be listed in the pom.xml with *all* relevant platform classifiers *for each javafx dependency*. There is also no need for unclassified javafx dependencies for such a build. – jewelsea Apr 20 '23 at 01:52
  • 1
    Use the same verison for *all* JavaFX dependencies and don't use `ea` versions. – jewelsea Apr 20 '23 at 01:55
  • I dont understand :( i tried it but i didn´t work. – markusnether Apr 20 '23 at 11:25
  • You can't be helped without a [mcve], a better description of what you are trying to do, and the actual commands you are running. Unless somebody can replicate your issues, your chance of receiving a more helpful answer is very low. If you don't understand something, then you need to explicitly explain what you don't understand, otherwise, others cannot understand what you don't understand. You can edit the question to improve it. – jewelsea Apr 20 '23 at 13:29
  • Can you look to this: https://stackoverflow.com/questions/76065181/javafx-application-dont-work-for-mac-when-i-am-adding-to-maven-two-dependencies?noredirect=1#comment134149898_76065181 I am not able to edit this question, because stacks says my question is a spam, when I try to edit it. I changed the pom a little bit, and now when I am deleting 2 dependencies, its works for mac user but then it dont work for linux and windows user – markusnether Apr 20 '23 at 16:01
  • 2
    @JdjdjwVdvdhdh Can you quote the exact text of the error message? I see no reason that this question would be considered spam, or why you'd be blocked from editing it. I was able to edit just fine. – EJoshuaS - Stand with Ukraine Apr 20 '23 at 16:28
  • 1
    [Being unresponsive to requests for clarification is not helpful.](http://idownvotedbecau.se/beingunresponsive) – EJoshuaS - Stand with Ukraine Apr 20 '23 at 21:01
  • Why did you place classified dependencies in your pom.xml? – jewelsea Apr 20 '23 at 23:48

1 Answers1

0

Use the JavaFX Maven plugin to automatically pull in the correct libraries for your platform:

<plugins>
    <plugin>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-maven-plugin</artifactId>
        <version>0.0.8</version>
        <configuration>
            <mainClass>HelloFX</mainClass>
        </configuration>
    </plugin>
</plugins>

and then to add dependencies on javafx.fxml and javafx.controls:

<dependencies>
  <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>${javafx.version}</version>
  </dependency>
  <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>${javafx.version}</version>
  </dependency>
</dependencies>
Elikill58
  • 4,050
  • 24
  • 23
  • 45
airsquared
  • 571
  • 1
  • 8
  • 25