0

I have a problem running my application with JavaFX on mac M1.

Intellij screenshot

Intellij screenshot

Even if I have downloaded the JavaFX SDK (aarch64 version) from the website, added as VM option in IntelliJ

--module-path "/Users/koloz/Downloads/javafx-sdk-18.0.1/lib" --add-modules=javafx.controls,javafx.fxml

and added the lib folder in the Project Structure -> Libraries

I still get this error:

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@18.0.1/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
    at javafx.graphics@18.0.1/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
    at javafx.graphics@18.0.1/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:266)
    at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics@18.0.1/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: Error initializing QuantumRenderer: no suitable pipeline found
    at javafx.graphics@18.0.1/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
    at javafx.graphics@18.0.1/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.base/java.lang.Thread.run(Thread.java:833)
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: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: No toolkit found
    at javafx.graphics@18.0.1/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:278)
    at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:291)
    at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:163)
    at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:659)
    at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:410)
    at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
    ... 5 more

It seems to me that I have done all the things (also extracting the "src" lib that was zipped) read on the web, I wonder if it's an m1 problem, even if I run it with a jar file I get bugs.

Here is my command line command:

java --module-path /Users/koloz/Downloads/javafx-sdk-18.0.1/lib --add-modules=javafx.controls,javafx.fxml -jar /Users/koloz/Desktop/s/coding/ing-sw-2022-restelli-secchi-sica2/out/artifacts/Eriantys_jar2/Eriantys.jar

I've read that aarch64 is the right version for m1 mac here:

Any help?

jewelsea
  • 150,031
  • 14
  • 366
  • 406
sickobb
  • 13
  • 5
  • added screenshot, module is in vm args, added command line – sickobb Jun 28 '22 at 19:27
  • Make sure your java/JDK is also AArch64. – José Pereda Jun 28 '22 at 19:30
  • If you want, you could follow the [guide in this answer](https://stackoverflow.com/a/71500774/1155209). Most likely I guess it will work then. For the packaging, see the [resources in the JavaFX tag](https://stackoverflow.com/tags/javafx/info), trying to package a JavaFX application as a jar can be problematic and it is easy to break things, usually other packaging mechanisms like jlink/jpackage are recommended. – jewelsea Jun 28 '22 at 19:43
  • Maybe upgrade your JDK to the most recent version (e.g. 18+), as was done in [this answer](https://stackoverflow.com/questions/72264772/javafx-not-working-on-my-macbook-m1-chipset). – jewelsea Jun 28 '22 at 19:54
  • Note, extracting src is not relevant to this, your issue is in the binary execution, not the JavaFX src. – jewelsea Jun 28 '22 at 19:57
  • @jewelsea from that guide i get that i'm creating a modular project, is that correct? but this project is shared so i should not change pom, module-info ecc.., i guess ? , my friends have no problems running fx on their enviroment – sickobb Jun 28 '22 at 20:17
  • 1
    @jewelsea now i'll try Zulu thanks so much for the help – sickobb Jun 28 '22 at 20:21
  • 1
    @jewelsea now it launches the application and something is shown!! But i still have bugs (IllegalStateException event loop object isn't active) if you want we can continue the analysis, otherwise i'll try to fix it mysefl, you tell me. – sickobb Jun 28 '22 at 20:37
  • That error "IllegalStateException: event loop object isn't active" is [generated here](https://github.com/jgneff/javafx-graphics/blob/master/src/javafx.graphics/classes/com/sun/glass/ui/EventLoop.java#L159). I don't know what causes it, probably improper startup or shutdown, or a violation of JavaFX threading rules. To get assistance you probably need to supply a [mcve] which can replicate the issue via copy and paste. The replicator may need an M1 or M2 Mac (which I don't have). You could either create a new question or update the existing one. I suggest a new question. – jewelsea Jun 28 '22 at 20:55
  • "from that guide i get that i'm creating a modular project, is that correct" -> yes, if you follow [these instructions](https://stackoverflow.com/questions/72264772/javafx-not-working-on-my-macbook-m1-chipset). – jewelsea Jun 28 '22 at 20:58
  • "but this project is shared so i should not change pom, module-info ecc" -> it is probably more portable as a modular project with Maven dependencies as then the project can be imported and run without manual SDK download or command line switch setting, but converting to a modular maven project would require your friends to update their runtime setup to allow the project to continue working. – jewelsea Jun 28 '22 at 20:59
  • In the new question regarding the event loop error, link back to this question for context. – jewelsea Jun 28 '22 at 21:00
  • Now that you are using ZuluFX distribution, you don't need command-line switches, older JDKs, or the JavaFX SDKs and you don't need to add JavaFX libraries to your IDE project settings, so you can remove all of those to ensure they don't interfere with your execution through a potential library mismatch. – jewelsea Jun 28 '22 at 22:01

1 Answers1

1

Zulu provides JDK versions for M1 that include JavaFX.

That would allow you to execute your application with no additional setup.

Choose the following options when performing the Zulu JDK download:

  • Java 18 (STS)
  • macOS
  • ARM 64-bit
  • JDK FX

It is important to choose "JDK FX", not "JDK" as only the "JDK FX" distribution includes the JavaFX modules.

Asker reports, after switching to use the Zulu JDK FX distribution:

now it launches the application and something is shown!! But i still have bugs (IllegalStateException event loop object isn't active)

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • the IllegalStateException was resolved in a really weird (i believe for my small knowledge) way, ill try to explain: in my application (a board game) i have a popup at first that asks the nickname and it is shown full window (? , in my friend's pc (a windows don't know if its important) it's shown just as a small popup and we have the same code), if i type my nickname there and click submit it throws then the IllegalState and starts bugging application even if it continues it's execution with bugs, BUT if i resize (with the green top left botton) the window and then click submit it works fine! – sickobb Jun 28 '22 at 22:08
  • don't know if you know something about this but i'm quite confused. @jewelsea – sickobb Jun 28 '22 at 22:11
  • @sikobb the "resolution" of the IllegalStateException still sounds like there is a bug somewhere (where I don't know). Also, whether it is platform-specific related to JavaFX or your JavaFX setup or something generic related to your code, I don't know. To get further assistance you need to create a new question with a [mcve] so that your issue could be replicated otherwise you will only get speculation. The example should not be your complete program, just the absolute minimal code which replicates the issue but is still compilable and executable without change. – jewelsea Jun 28 '22 at 22:19