我一直在尝试为一个项目下载JavaFX,当我尝试运行gradle时,我的笔记本电脑就是没有它。
我可以很好地构建gradle,但是当我尝试gradle run时,我得到了这样的消息:
> Configure project :
Project : => no module-info.java found
> Task :run FAILED
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib: dlopen(/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib, 0x0001): tried: '/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
java.lang.UnsatisfiedLinkError: /Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib: dlopen(/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib, 0x0001): tried: '/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
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:2404)
at java.base/java.lang.Runtime.load0(Runtime.java:817)
at java.base/java.lang.System.load(System.java:2015)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:217)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:197)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:138)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
at javafx.graphics@20/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:63)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at javafx.graphics@20/com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:52)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:391)
at java.base/java.lang.Class.forName(Class.java:382)
at javafx.graphics@20/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:92)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:1623)
Loading library prism_sw from resource failed: java.lang.UnsatisfiedLinkError: /Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib: dlopen(/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib, 0x0001): tried: '/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
java.lang.UnsatisfiedLinkError: /Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib: dlopen(/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib, 0x0001): tried: '/Users/claretian/.openjfx/cache/20+19/aarch64/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
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:2404)
at java.base/java.lang.Runtime.load0(Runtime.java:817)
at java.base/java.lang.System.load(System.java:2015)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:217)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:197)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:138)
at javafx.graphics@20/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
at javafx.graphics@20/com.sun.prism.sw.SWPipeline.lambda$static$0(SWPipeline.java:43)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at javafx.graphics@20/com.sun.prism.sw.SWPipeline.<clinit>(SWPipeline.java:42)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:391)
at java.base/java.lang.Class.forName(Class.java:382)
at javafx.graphics@20/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:92)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:1623)
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@20/com.sun.javafx.tk.quantum.QuantumRenderer.getInstance(QuantumRenderer.java:283)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumToolkit.init(QuantumToolkit.java:253)
at javafx.graphics@20/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:263)
at javafx.graphics@20/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:290)
at javafx.graphics@20/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:162)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:651)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
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@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:95)
at javafx.graphics@20/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
at java.base/java.lang.Thread.run(Thread.java:1623)
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@20/com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:275)
at javafx.graphics@20/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:290)
at javafx.graphics@20/com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:162)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:651)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:409)
at javafx.graphics@20/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 2 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Users/claretian/.sdkman/candidates/java/20.0.2-amzn/bin/java'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 2s
3 actionable tasks: 2 executed, 1 up-to-date
我很确定这与架构不兼容有关,但我已经尝试下载我能找到的每个版本的JavaFX。
1条答案
按热度按时间u5rb5r591#
tl; dr
你似乎有两个问题:
module-java.java
文件模块化
显然,您的配置的某些部分或某些库希望您的项目按照Java Platform Module System (JPMS)进行模块化。我这样说是因为你的错误:
项目:=>未找到www.example.com
module-java.java
文件是指定模块配置的地方。显然你没有。获取JavaFX技术
访问JavaFX的三种途径:
对于刚开始涉足JavaFX的人,我建议使用JDK选项。
下载库
您可以告诉Gradle下载实现JavaFX的必要OpenJFX库。
一种简单的方法是使用与IntelliJIDE捆绑在一起的JavaFX新项目模板。
将版本号更新为最新版本后,
build.gradle
文件可能如下所示。JDK捆绑JavaFX
几个JDK供应商中至少有两个提供了一个版本的JDK产品,其中包括实现JavaFX的必要OpenJFX库。
这些公司也可能出售对JavaFX的支持,JavaFX的联合领导者Gluon和Oracle也可能这样做。
为了最容易地下载和安装这些JDK,我建议在Mac上安装SDKMAN!。这个方便的shell脚本包使得下载/安装/卸载工作变得非常简单和方便。就运行这个:
......得到这个:
要查看通过SDKMAN提供的所有JDK产品的列表!,运行以下命令:
原生代码
要知道JavaFX不是纯Java。所需的库包含一些特定于特定主机OS和特定主机芯片(instruction set architecture)的本机代码。
对于您的M1 Mac,您需要在具有Apple Silicon的Mac上运行macOS的JavaFX版本。您可能会看到与Apple Silicon兼容的aarch64或ARM选项。
您的错误消息表明您确实安装了错误的芯片架构:
mach-o文件,但是不兼容的体系结构(have(x86_64),need(arm64e))