MacBook M1(Sonoma 14.4.1)下Eclipse启动失败(XstartOnFirstThread问题)
Eclipse在MacBook M1 Sonoma 14.4.1上启动闪退,已配置-XstartOnFirstThread仍报错
问题详情
设备:MacBook M1,系统版本Sonoma 14.4.1
此前Eclipse可正常使用,一周未使用后启动时中途闪退,无重大系统或软件变更。执行./eclipse -clean启动后,日志反复出现以下警告:
./eclipse -clean 2024-05-02 10:15:51.560 eclipse[1725:23581] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. May 02, 2024 10:15:55 AM org.apache.aries.spifly.BaseActivator log INFO: Registered provider ch.qos.logback.classic.spi.LogbackServiceProvider of service org.slf4j.spi.SLF4JServiceProvider in bundle ch.qos.logback.classic 10:15:58.790 [Start Level: Equinox Container: e184951f-302b-438d-bcaa-7b4c398c21a2] DEBUG org.eclipse.jgit.internal.util.ShutdownHook -- register org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$180/0x000000001726e3f8@4fd63d35 with shutdown hook 10:15:58.790 [Start Level: Equinox Container: e184951f-302b-438d-bcaa-7b4c398c21a2] DEBUG org.eclipse.jgit.internal.util.ShutdownHook -- register org.eclipse.jgit.util.FS$FileStoreAttributes$$Lambda$180/0x000000001726e3f8@4fd63d35 with shutdown hook WARNING: Annotation classes from the 'javax.inject' or 'javax.annotation' package found. It is recommended to migrate to the corresponding replacements in the jakarta namespace. The Eclipse E4 Platform will remove support for those javax-annotations in a future release. To suppress this warning, set the VM property: -Declipse.e4.inject.javax.warning=false To disable processing of 'javax' annotations entirely, set the VM property: -Declipse.e4.inject.javax.disabled=true ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread
但eclipse.ini已配置-XstartOnFirstThread参数,配置内容如下:
-startup ../Eclipse/plugins/org.eclipse.equinox.launcher_1.6.600.v20231106-1826.jar --launcher.library ../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.2.800.v20231003-1442 -product org.eclipse.epp.package.java.product --launcher.defaultAction openFile --launcher.appendVmargs -vm ../Eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.x86_64_17.0.10.v20240120-1143/jre/lib/libjli.dylib -vmargs -XstartOnFirstThread -Dorg.eclipse.equinox.log.file=/Users/eclipse_log -Dosgi.framework.extensions=org.eclipse.osgi.logger.bundleLog -Dsun.java.command=Eclipse -Dosgi.requiredJavaVersion=17 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=false --add-modules=ALL-SYSTEM --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED --add-opens=java.desktop/java.beans=ALL-UNNAMED -Dorg.eclipse.swt.internal.carbon.smallFonts -Xdock:icon=../Resources/Eclipse.icns -XX:+UseParallelGC -XX:InitialRAMPercentage=5 -XX:MaxRAMPercentage=25 -XX:TieredStopAtLevel=1 -javaagent:lombok.jar
确认配置无误后启动仍闪退,求解决方法。
解决步骤
1. 修正JDK架构适配问题
你的配置中使用的是x86_64版本的JDK,M1为arm64架构,跨架构兼容性问题可能导致启动失败:
- 下载适配arm64的JDK17(比如Eclipse官方的JustJ arm64版本,或Azul Zulu arm64)
- 修改eclipse.ini的
-vm路径,指向arm64 JDK的libjli.dylib文件 - 示例:
../Eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.macosx.aarch64_17.0.10.v20240120-1143/jre/lib/libjli.dylib
2. 确保Eclipse读取正确的配置文件
Mac上Eclipse.app的内置配置可能未被正确修改:
- 右键Eclipse.app → 显示包内容 → 进入
Contents/Eclipse目录 - 确认你修改的是该目录下的eclipse.ini,而非外部备份或其他位置的文件
3. 完全清除缓存与工作区配置
-clean命令可能未彻底清除缓存:
- 关闭Eclipse,删除工作区目录下的
.metadata文件夹(先备份项目文件) - 或启动时指定全新工作区:
./eclipse -clean -data ~/Documents/NewEclipseWorkspace - 同时删除
~/Library/Application Support/Eclipse目录(备份后删除)
4. 排查Lombok代理冲突
配置中的-javaagent:lombok.jar可能与当前环境不兼容:
- 暂时注释掉eclipse.ini中的
-javaagent:lombok.jar行,重新启动 - 若能正常启动,更新Lombok至支持JDK17和当前Eclipse版本的最新版,再重新添加代理配置
5. 调整显示相关VM参数
添加额外参数规避MacOS显示框架限制:
- 在eclipse.ini的
-vmargs区块中添加:-Dorg.eclipse.swt.internal.carbon.noFocusRing=true - 保存后重新启动Eclipse
内容的提问来源于stack exchange,提问作者aska
相关产品推荐
相关产品推荐

