在 Maven 中编译 JavaFX 项目时,从资源加载库 prism_es2 失败

问题描述 投票:0回答:1

最近我在尝试编译 JavaFx 项目时遇到了 IntelliJ Idea 的问题。

这是错误消息(堆栈跟踪):

/opt/homebrew/Cellar/openjdk@21/21.0.3/libexec/openjdk.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=60420:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/nemethhunor/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13.jar:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13.jar:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13.jar:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13.jar -p /Users/nemethhunor/.m2/repository/org/openjfx/javafx-graphics/13/javafx-graphics-13-mac.jar:/Users/nemethhunor/IdeaProjects/untitled/target/classes:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13-mac.jar:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13-mac.jar:/Users/nemethhunor/.m2/repository/org/openjfx/javafx-fxml/13/javafx-fxml-13-mac.jar -m org.example/org.example.App
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib: dlopen(/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib, 0x0001): tried: '/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (no such file), '/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
java.lang.UnsatisfiedLinkError: /Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib: dlopen(/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib, 0x0001): tried: '/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (no such file), '/Users/nemethhunor/.openjfx/cache/13/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
    at java.base/java.lang.Runtime.load0(Runtime.java:852)
    at java.base/java.lang.System.load(System.java:2025)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
    at javafx.graphics/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:68)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
    at javafx.graphics/com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:50)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:421)
    at java.base/java.lang.Class.forName(Class.java:412)
    at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Loading library prism_sw from resource failed: java.lang.UnsatisfiedLinkError: /Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib: dlopen(/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib, 0x0001): tried: '/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (no such file), '/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
java.lang.UnsatisfiedLinkError: /Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib: dlopen(/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib, 0x0001): tried: '/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (no such file), '/Users/nemethhunor/.openjfx/cache/13/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
    at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
    at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2418)
    at java.base/java.lang.Runtime.load0(Runtime.java:852)
    at java.base/java.lang.System.load(System.java:2025)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
    at javafx.graphics/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
    at javafx.graphics/com.sun.prism.sw.SWPipeline.lambda$static$0(SWPipeline.java:42)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
    at javafx.graphics/com.sun.prism.sw.SWPipeline.<clinit>(SWPipeline.java:41)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:421)
    at java.base/java.lang.Class.forName(Class.java:412)
    at javafx.graphics/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
    at java.base/java.lang.Thread.run(Thread.java:1583)
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/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:260)
    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.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1135)
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:1583)
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1135)
Caused by: java.lang.RuntimeException: No toolkit found
    at javafx.graphics/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
    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.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    ... 2 more

我该怎么办?我使用的系统是ARM架构上的Mac OS 14.5。

感谢您的回答!

我尝试安装SDKMAN,但没有成功。 我重新安装了javafx-sdk-23。

java maven intellij-idea javafx
1个回答
0
投票

因为您有M系列Mac,所以无论您使用哪个JavaFX版本,请确保它是Mac aarch64架构版本而不是Mac x64架构版本。 目前,您正在尝试使用仅针对 Intel/AMD 处理器编译的 JavaFX 版本,而不是针对 Apple 的 M 处理器,并且 Apple 机器无法处理 x64 代码。

如果使用 Gluon 的 JavaFX SDK,请从下拉列表中选择 23:macOS:aarch64:SDK。 根据需要调整版本号以使用最新的稳定版本或长期服务(LTS)版本。

如果使用 Maven,它应该为您选择正确分类的版本 (mac-aarch64),但仅限于更高版本的 JavaFX 版本(例如 21+)。

我对 SDKMAN 一无所知,所以无法建议如何使用 JavaFX。

在你的问题中,你提到你“安装了javafx-sdk-23”,但执行有来自Maven的JavaFX 13,

/Users/nemethhunor/.m2/repository/org/openjfx/javafx-controls/13/javafx-controls-13.jar

,所以那里的东西看起来不正确。

您使用的 JavaFX 版本比您想象的版本低 10 个版本。 JavaFX 13 中不支持 M 系列 Mac(aarch64 处理器),因为当时不存在 M 系列 Mac,因此这样过时的 JavaFX 版本永远无法在您的计算机上运行。

© www.soinside.com 2019 - 2024. All rights reserved.