IntelliJ IDEA Gradle同步:将Gradle的Java主页设置为某些JDK时出现问题 [英] IntelliJ IDEA Gradle sync: Problem with setting Gradle's Java home to some JDKs

查看:497
本文介绍了IntelliJ IDEA Gradle同步:将Gradle的Java主页设置为某些JDK时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没问题:

  1. org.gradle.java.home=C:/Program Files/Java/openjdk1.8.0_202

我的(全局)gradle.properties文件中的

.同样,没有它也没有问题(未设置任何内容).但是,如果将其替换为以下配置之一(所有路径均有效):

in my (global) gradle.properties file. Also, no problem without it (with nothing set). But if replace it with one of below configurations (all paths are valid):

  1. org.gradle.java.home=C:/Program Files/Java/openjdk-9.0.4
  2. org.gradle.java.home=C:/Program Files/Java/openjdk-10.0.1
  3. org.gradle.java.home=C:/Program Files/Java/openjdk-11.0.1
  4. org.gradle.java.home=C:\\Program Files\\Java\\oraclejdk-11.0.1
  1. org.gradle.java.home=C:/Program Files/Java/openjdk-9.0.4
  2. org.gradle.java.home=C:/Program Files/Java/openjdk-10.0.1
  3. org.gradle.java.home=C:/Program Files/Java/openjdk-11.0.1
  4. org.gradle.java.home=C:\\Program Files\\Java\\oraclejdk-11.0.1

然后我在 IntelliJ IDEA 中保存文件并导入Gradle更改后,会收到一条错误消息(每个消息都相同):

then I will get an error message (same for each) after I save the file and import Gradle changes in IntelliJ IDEA:

无法启动守护进程. 此问题可能是由守护程序的错误配置引起的. 例如,使用无法识别的jvm选项. 请在 https://docs.gradle.org上参阅守护程序上的用户指南一章. /5.0/userguide/gradle_daemon.html

Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at https://docs.gradle.org/5.0/userguide/gradle_daemon.html

请阅读以下过程输出以了解更多信息:

Please read the following process output to find out more:

OpenJDK 64位服务器VM警告:忽略选项MaxPermSize;在8.0中删除了支持 错误:找不到或加载主类java.base.java.lang = ALL-UNNAMED 由以下原因引起:java.lang.ClassNotFoundException:java.base.java.lang = ALL-UNNAMED

OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0 Error: Could not find or load main class java.base.java.lang=ALL-UNNAMED Caused by: java.lang.ClassNotFoundException: java.base.java.lang=ALL-UNNAMED


请注意,此问题仅适用于 IDE Gradle同步. Gradle任务本身可以正常运行(独立于IDE)!即使当我运行gradle --status时(关于它,请参见此处 )可以看到一切正常,并且守护程序正在使用JDK 11运行:


The note is the issue is only for IDE Gradle sync. Gradle tasks themselves work correctly (independent from IDE)! Even when I run gradle --status (see here about it) can see everything is OK and daemon is running using JDK 11:

>gradlew --status
   PID STATUS   INFO
 10668 IDLE     5.0

PID: 10668的路径:

>wmic process where "processId=10668" get Name, ProcessID, ExecutablePath
ExecutablePath                                     Name      ProcessId
C:\Program Files\Java\openjdk-11.0.1\bin\java.exe  java.exe  10668

推荐答案

最后,我发现问题出在我的IDE设置中.它来自 SDK表.

Finally, I found out the issue was from my IDE settings. It was from SDK Table.

我不知道为什么从Project Structure(或Other Settings中的Structure for new Projects)更正它们不能解决问题.最后,我从一个全新的安装导入了(并且只有它).

I don't know why correcting them from Project Structure (or Structure for new Projects in Other Settings) couldn't solve the issue. Finally, I imported it (and only it) from a fresh installation.

注意:您实际上不需要全新安装.刚好足以关闭您的IDE,将其配置目录,然后重新打开它.

Note: You don't need a fresh installation really. Just enough to close your IDE, rename its configuration directory and re-open it.

然后,IDE重新启动.这是测试的机会.如果确定,则导出指向的设置... 文件 -> 导出设置... :

Then IDE starts freshly. This is an opportunity for the test. If OK export pointed setting ... File -> Export Settings ...:

到文件.然后返回到先前的状态并导入导出的文件:

to a file. Then return to your previous state and import the exported file:

如果问题恢复,则需要检查其他设置( SDK表除外).

If the issue reverted you need to check other settings (other than SDK Table).

这篇关于IntelliJ IDEA Gradle同步:将Gradle的Java主页设置为某些JDK时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆