Problem with JavaFX and Apple M1 (Silicon) Chip and Eclipse

Viewed 1314

Update: After several trials I figured out a workaround to get this JavaFX / Apple M1 (Silicon) / Eclipse problem: When installing Eclipse 2021-09, use JRE 17.0.0, https://download.eclipse.org/justj/jres/17/updates/release/17.0.0, in the installer form for the Java 11+ VM specification.

With this JRE at hand, the JavaFX application can be started successfully from within Eclipse. Changing the project's JRE back to another Java 17 JRE, however, still yields the problem described below.

I report here another problem I have encountered when running a JavaFX 17 application from within Eclipse on a brand-new Apple M1 (Silicon) based laptop.

Executing the simple Hello World app from within Eclipse (right-click class App / Run As / Java Application) yields the following stack trace:

Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/due1/.openjfx/cache/17.0.0.1/libprism_es2.dylib: dlopen(/Users/due1/.openjfx/cache/17.0.0.1/libprism_es2.dylib, 1): no suitable image found.  Did find:
    /Users/due1/.openjfx/cache/17.0.0.1/libprism_es2.dylib: mach-o, but wrong architecture
    /Users/due1/.openjfx/cache/17.0.0.1/libprism_es2.dylib: mach-o, but wrong architecture
...

Inspecting the user's cache for JavaFX shared libraries yields:

due1@host 17.0.0.1 % file * 
libglass.dylib:       Mach-O 64-bit dynamically linked shared library arm64
libjavafx_font.dylib: Mach-O 64-bit dynamically linked shared library arm64
libprism_es2.dylib:   Mach-O 64-bit dynamically linked shared library x86_64
libprism_sw.dylib:    Mach-O 64-bit dynamically linked shared library x86_64

Clearly, files libprism_es2.dylib and libprism_sw.dylib are not one for the required M1 chip architecture.

However, if executed via Eclipse's Maven command, the application can be executed:

...
[INFO] --- javafx-maven-plugin:0.0.6:run (default-cli) @ hellomvn ---
[INFO] Toolchain in javafx-maven-plugin null
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Having imported the project into IntelliJ 2021.2.x, the simple application can be executed. Then, the user's cache for JavaFX shared libraries looks like:

due1@host 17.0.0.1 % file *
libglass.dylib:       Mach-O 64-bit dynamically linked shared library arm64
libjavafx_font.dylib: Mach-O 64-bit dynamically linked shared library arm64
libprism_es2.dylib:   Mach-O 64-bit dynamically linked shared library arm64

And it seems that file libprism_sw.dylib (see Eclipse case) is not used.

Any clue?

0 Answers
Related