You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ARM架构Mac上Maven编译JavaFX项目时prism_es2库加载失败求助

解决ARM架构Mac上JavaFX项目架构不兼容的运行错误

错误原因分析

从日志能明确看到:项目加载的是JavaFX 13版本的x86_64架构本地库,但你的ARM架构Mac需要arm64/arm64e版本的库;同时你已安装JavaFX 23 SDK,但项目依赖仍停留在旧版本,版本与架构双重不匹配,导致无法初始化渲染管道。


解决步骤

1. 清理旧版本JavaFX缓存

删除本地缓存的x86_64架构旧库,避免系统重复加载错误文件:

rm -rf ~/.openjfx/cache/13

2. 统一项目JavaFX版本为23(适配ARM架构)

Maven项目(日志显示为Maven管理)

修改pom.xml,将所有JavaFX依赖版本改为23,并指定ARM架构的classifier:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>23</version>
        <classifier>mac-aarch64</classifier>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-graphics</artifactId>
        <version>23</version>
        <classifier>mac-aarch64</classifier>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-base</artifactId>
        <version>23</version>
        <classifier>mac-aarch64</classifier>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>23</version>
        <classifier>mac-aarch64</classifier>
    </dependency>
</dependencies>

同时更新Maven插件配置,确保版本匹配:

<build>
    <plugins>
        <plugin>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>0.0.8</version>
            <configuration>
                <mainClass>org.example/org.example.App</mainClass>
                <options>
                    <option>--add-modules</option>
                    <option>javafx.controls,javafx.fxml</option>
                </options>
            </configuration>
        </plugin>
    </plugins>
</build>
IntelliJ运行配置调整
  • 打开「Run/Debug Configurations」,找到你的JavaFX运行配置
  • 在「VM options」中添加ARM适配的模块路径(替换为你实际的JavaFX 23 SDK路径):
    --module-path /你的路径/javafx-sdk-23/lib --add-modules javafx.controls,javafx.fxml
    

3. 确认JDK为ARM版本

你的日志显示使用Homebrew的openjdk@21,验证是否为ARM版本:

java -version

输出需包含aarch64字样,若为x86_64版本,重新安装ARM版:

brew uninstall openjdk@21
brew install openjdk@21

4. 重新构建项目

  • 在IntelliJ中执行「Maven → Clean → Install」,清理旧依赖并下载适配架构的新库
  • 重启IntelliJ后运行项目

内容的提问来源于stack exchange,提问作者Hunor Németh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 17:32:02