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

Java游戏在IntelliJ运行正常,导出JAR报错,已降级至JDK 11解决

导出可执行JAR报错"A Java Exception has occurred",IDE内运行正常的解决案例

问题现象

  • 开发的练习用简易游戏在IntelliJ IDE中运行完全正常;
  • 导出为可执行JAR文件后,直接启动抛出"A Java Exception has occurred"错误;
  • 但在IDE环境内执行该导出的JAR文件,却能正常运行。

排查过程

  1. 首先怀疑依赖库未打包进JAR:项目仅依赖org.json库处理高分存档JSON文件,确认该库已添加到项目,且物理存在于导出的JAR文件中。
  2. 以下是org.json库的MANIFEST.MF内容:
Manifest-Version: 1.0
Automatic-Module-Name: org.json
Bnd-LastModified: 1677505062321
Build-Jdk: 1.8.0_271
Built-By: stlea
Bundle-Description: JSON is a light-weight, language independent, data interchange format.        See http://www.JSON.org/        The files in this package implement JSON encoders/decoders in Java.        It also includes the capability to convert between JSON and XML, HTTP headers, Cookies, and CDL.        This is a reference implementation. There is a large number of JSON packages in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully.
Bundle-License: https://github.com/stleary/JSON-java/blob/master/LICENSE
Bundle-ManifestVersion: 2
Bundle-Name: JSON in Java
Bundle-SymbolicName: json
Bundle-Version: 20230227.0.0
Created-By: Apache Maven Bundle Plugin
Export-Package: org.json;version="20230227.0.0"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))"
Tool: Bnd-3.0.0.201509101326

最终解决方案

尝试多种排查方法无效后,定位问题为JDK版本不兼容,将项目编译运行的JDK版本降级至JDK 11后,导出的可执行JAR文件可正常启动,不再报错。

内容的提问来源于stack exchange,提问作者VMOrihuela

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 03:58:11