我正试图用m1芯片在我的macbook上用intelij启动一个javaFX项目.

这是java退出时的日志(log):

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000115378ac8, pid=20632, tid=259
#
# JRE version: OpenJDK Runtime Environment Zulu16.32+15-CA (16.0.2+7) (build 16.0.2+7)
# Java VM: OpenJDK 64-Bit Server VM Zulu16.32+15-CA (16.0.2+7, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# J 343 c2 java.lang.StringLatin1.indexOf([BII)I java.base@16.0.2 (36 bytes) @ 0x0000000115378ac8 [0x0000000115378ac0+0x0000000000000008]
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://www.azul.com/support/
#

---------------  S U M M A R Y ------------

Command Line: --module-path=/Users/moemenhussein/.m2/repository/org/openjfx/javafx-base/18.0.1/javafx-base-18.0.1-mac-aarch64.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-base/18.0.1/javafx-base-18.0.1.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-controls/18.0.1/javafx-controls-18.0.1-mac-aarch64.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-controls/18.0.1/javafx-controls-18.0.1.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-fxml/18.0.1/javafx-fxml-18.0.1-mac-aarch64.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-fxml/18.0.1/javafx-fxml-18.0.1.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-graphics/18.0.1/javafx-graphics-18.0.1-mac-aarch64.jar:/Users/moemenhussein/.m2/repository/org/openjfx/javafx-graphics/18.0.1/javafx-graphics-18.0.1.jar --add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics Main

Host: MacBookAir10,1 arm64 1 MHz, 8 cores, 8G, Darwin 21.4.0, macOS 12.3.1 (21E258)
Time: Mon May 16 20:00:48 2022 CEST elapsed time: 0.886937 seconds (0d 0h 0m 0s)

---------------  T H R E A D  ---------------

Current thread (0x000000015700e800):  JavaThread "JavaFX Application Thread" [_thread_in_Java, id=259, stack(0x000000016ae14000,0x000000016ce14000)]

Stack: [0x000000016ae14000,0x000000016ce14000],  sp=0x000000016c62bd10,  free space=24671k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
J 343 c2 java.lang.StringLatin1.indexOf([BII)I java.base@16.0.2 (36 bytes) @ 0x0000000115378ac8 [0x0000000115378ac0+0x0000000000000008]
V  [libjvm.dylib+0x4217e4]  _ZN13InstanceKlass17allocate_objArrayEiiP6Thread+0x144
V  [libjvm.dylib+0x80609c]  _ZN11OptoRuntime11new_array_CEP5KlassiP10JavaThread+0x1ec


siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x000000016c617d10

Register to memory mapping:

 x0=0x00000007403e7d88 is an oop: java.lang.String 
{0x00000007403e7d88} - klass: 'java/lang/String'
 x1=0x000000074034a248 is an oop: [B 
{0x000000074034a248} - klass: {type array byte}
 - length: 1
 x2=0x000000000000003f is an unknown value
 x3=0x0 is NULL
 x4=0x0 is NULL
 x5=0x0000000000000001 is an unknown value
 x6=0x0000000740353a78 is an oop: java.lang.String 
{0x0000000740353a78} - klass: 'java/lang/String'
 x7=0x0 is NULL
 x8=0x00000000000409f8 is an unknown value
 x9=

当我try 从maven选项卡运行项目时."javafx:run".我收到以下错误:

[INFO] 
[INFO] --- javafx-maven-plugin:0.0.6:run (default-cli) @ El_Dorado ---
[INFO] Toolchain in javafx-maven-plugin null
Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_es2.dylib: dlopen(/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_es2.dylib, 0x0001): tried: '/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
java.lang.UnsatisfiedLinkError: /Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_es2.dylib: dlopen(/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_es2.dylib, 0x0001): tried: '/Users/moemenhussein/.openjfx/cache/18.0.1+2/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:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
    at java.base/java.lang.Runtime.load0(Runtime.java:746)
    at java.base/java.lang.System.load(System.java:1857)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:217)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:197)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:138)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
    at javafx.graphics@18.0.1/com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:63)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
    at javafx.graphics@18.0.1/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:375)
    at javafx.graphics@18.0.1/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
    at javafx.graphics@18.0.1/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:92)
    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:831)
Loading library prism_sw from resource failed: java.lang.UnsatisfiedLinkError: /Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_sw.dylib: dlopen(/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_sw.dylib, 0x0001): tried: '/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
java.lang.UnsatisfiedLinkError: /Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_sw.dylib: dlopen(/Users/moemenhussein/.openjfx/cache/18.0.1+2/libprism_sw.dylib, 0x0001): tried: '/Users/moemenhussein/.openjfx/cache/18.0.1+2/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:383)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:227)
    at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:169)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2383)
    at java.base/java.lang.Runtime.load0(Runtime.java:746)
    at java.base/java.lang.System.load(System.java:1857)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:217)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:197)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:138)
    at javafx.graphics@18.0.1/com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:54)
    at javafx.graphics@18.0.1/com.sun.prism.sw.SWPipeline.lambda$static$0(SWPipeline.java:43)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
    at javafx.graphics@18.0.1/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:375)
    at javafx.graphics@18.0.1/com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
    at javafx.graphics@18.0.1/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:92)
    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:831)
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:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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:831)
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:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    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
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:567)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine (JavaFXBaseMojo.java:434)
    at org.openjfx.JavaFXRunMojo.execute (JavaFXRunMojo.java:105)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
    at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
    at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:567)
    at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:434)
    at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:105)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

我真的不知道该怎么办了,我已经将其添加到了我的"vm选项"(我还将lib文件夹添加到了我的项目 struct 中的Modules-&gt;dependencies下):

--module-path "/Users/moemenhussein/Documents/JavaFX/javafx-sdk-18.0.1/lib" --add-modules=javafx.controls,javafx.fxml

还有我的pom.xml确实如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>El_Dorado</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>15</maven.compiler.source>
        <maven.compiler.target>15</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>18.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>18.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-graphics</artifactId>
            <version>18.0.1</version>
            <classifier>mac</classifier>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.8.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.6</version>
                <configuration>
                    <mainClass>Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

谢谢你的帮助!

推荐答案

我从JosePereda的 comments 中得到了答案,他说我必须使用更新的JDK.我使用的是JDK 16.0.2,他说我必须至少使用JDK 17.0.2.

因此,我将JDK升级到18.0.1.您可以在intelij self中下载JDK,但这对我不起作用.所以我从https://adoptium.net/下载了它,并下载了aarch64版本.

Java相关问答推荐

是否需要关闭Executors返回的执行器.newVirtualThreadPerTaskExecutor()?

查找最大子数组的和

Jooq外键关系

在Java Stream上调用collect方法出现意外结果

使用动态ID从json获取详细信息的Jolt规范

Jlink选项&-strie-ative-Commands";的作用是什么?

Jenv-相同的Java版本,但带有前缀

对字符串长度进行排序,但颠倒了顺序(最长字符串在前)

将Spring Boot 3.2.0升级到3.2.1后查询执行错误

如何使用MapStrCut转换双向链接

无法使用Java PreparedStatement在SQLite中的日期之间获取结果

在一行中检索字符分隔字符串的第n个值

如何在Java中使用正则表达式拆分字符串

RestTemplate Bean提供OkHttp3ClientHttpRequestFactory不支持Spring Boot 3中的请求正文缓冲

在单例类上获取Java锁,了解原因

如何在特定关键字后提取与模式匹配的多个值?

Java 21保护模式的穷尽性

如何从指定某些字段的父对象创建子对象

如何在Java中正确实现填字游戏求解器

在数组列表中找到对象后,未从数组中删除对象