IDea 报错 Error: Could not create the Java Virtual Machine. Unrecognized option: --add-opens

网上搜了一圈, 都说这是jdk 9的参数, 我用 jdk 8就要报错, 实际上解决方法很简单

报错如下:

C:\Users\HW\.jabba\jdk\default\bin\java.exe -Xmx700m -Djava.awt.headless=true "-Djna.boot.library.path=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.1/lib/jna/amd64" -Djna.nosys=true -Djna.noclasspath=true --add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dexternal.project.config=C:\Users\HW\AppData\Local\JetBrains\IdeaIC2024.1\projects\yuguan-backend.8de06894\external_build_system -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Didea.IntToIntBtree.page.size=32768 -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=2150057486439607630 -Dfile.encoding=GBK -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IdeaIC2024.1 "-Didea.home.path=C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1" -Didea.config.path=C:/Users/HW/AppData/Roaming/JetBrains/IdeaIC2024.1 -Didea.plugins.path=C:/Users/HW/AppData/Roaming/JetBrains/IdeaIC2024.1/plugins -Djps.log.dir=C:/Users/HW/AppData/Local/JetBrains/IdeaIC2024.1/log/build-log "-Djps.fallback.jdk.home=C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/jbr" -Djps.fallback.jdk.version=17.0.10 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/HW/AppData/Local/JetBrains/IdeaIC2024.1/compile-server/yuguan-backend_acfae7b0/_temp_ -Djps.backward.ref.index.builder=true "-Djps.kotlin.home=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2024.1\plugins\Kotlin\kotlinc" -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"C:\Users\HW\AppData\Local\Temp\kotlin-idea-6093052720390690581-is-running\" -Dide.propagate.context=false -classpath "C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-launcher.jar" org.jetbrains.jps.cmdline.Launcher "C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-builders.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-builders-6.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jps-javac-extension.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/util-8.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/util_rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/platform-loader.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/annotations.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/trove.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/jetbrains.kotlinx.metadata.jvm.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/protobuf.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/jps-model.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/javac2.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/forms_rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/util.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/aether-dependency-resolver.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/maven-resolver-connector-basic.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/maven-resolver-transport-file.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/java/lib/maven-resolver-transport-http.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/idea_rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/lib/util-8.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/eclipse/lib/eclipse-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/eclipse/lib/eclipse-common.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/platform-langInjection/lib/java-langInjection-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/Groovy/lib/groovy-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/Groovy/lib/groovy-constants-rt.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/javaFX/lib/javaFX-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/javaFX/lib/javaFX-common.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/maven/lib/maven-jps.jar;C:/Program Files/JetBrains/IntelliJ IDEA Community Edition 2024.1/plugins/gradle-java/lib/gradle-jps.jar" org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 9261 1c7649b0-ceb4-48ae-9c3c-36228e7f424d C:/Users/HW/AppData/Local/JetBrains/IdeaIC2024.1/compile-server
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --add-opens

解决办法:

不用怀疑idea的问题, 要检查你的jdk是否一致

File->Project Structure 我把多余的sdks全部删除掉, 换成命令行一致的环境变量, 然后重新设置一下sdk, 另外记得全部删除掉, 重新添加, 然后就比较爽快啦

将project , modules重新设置成当前的sdk

### 解决方案 当遇到 `Unrecognized option: --patch-module` 错误时,这通常意味着使用的JVM版本不支持该选项。此错误表明尝试启动SonarQube的过程中遇到了与Java模块化系统相关的配置问题[^1]。 对于这个问题有几种可能的原因和解决方案: #### 1. 使用兼容的 JDK 版本 确保正在使用的是一个完全支持这些参数的JDK版本。较新的JDK版本(如9及以上)引入了诸如`--add-exports`这样的新特性,而更早版本则不会认识它们。如果项目依赖于特定的JDK功能,则应安装并切换到适当版本的JDK环境变量设置。 #### 2. 修改启动脚本中的 JVM 参数 检查用于启动应用程序的服务文件或批处理/Shell脚本里是否有不必要的JVM参数被硬编码进去。移除任何可能导致冲突或者当前运行环境中不需要的参数声明。 ```bash # Example of removing or commenting out problematic parameters from startup script # Remove lines like these if present: # JAVA_OPTS="$JAVA_OPTS --add-exports java.base/jdk.internal.ref=ALL-UNNAMED" ``` #### 3. 更新软件包至最新稳定版 有时官方发布的更新会修复已知的问题以及提高与其他工具链组件之间的兼容性。因此建议定期查看所用产品的发行说明,并考虑升级到最新的稳定版本以获得更好的体验和支持。 通过以上方法可以有效解决由于`--patch-module`等未识别选项引起的Java虚拟机创建失败问题。值得注意的是,在做出更改之前最好先备份现有配置文件以便回滚操作;另外也要注意不同平台之间可能存在细微差异,所以实际执行过程中需参照具体文档指导来进行调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值