使用IntelliJ IDEA 2018.1.2创建Gradle项目时Java版本识别失败怎么解决?
I ran into this exact problem while trying to spin up a new Gradle project with IntelliJ IDEA 2018.1.2, and here's what worked to fix it:
The Error I Encountered
When the IDE attempted to sync the Gradle project, this error message appeared:
sync failed: Could not determine Java version using executable
C:\Program Files\Java\jdk-10.0.1\bin\java.exe
Why This Happens
IntelliJ IDEA 2018.1.2 is an older release that lacks full compatibility with JDK 10. The Gradle versions typically paired with this IDE also don't properly support JDK 10, which leads to the failed Java version detection during sync.
The Solution That Resolved It
I fixed the issue by switching to JDK 8, which is fully compatible with IDEA 2018.1.2 and most Gradle versions from that era:
- Uninstall JDK 10.0.1 from your Windows system (go to Control Panel > Programs > Programs and Features, locate JDK 10.0.1, and uninstall it).
- Download a stable release of JDK 8 and install it on your machine.
- Open IntelliJ IDEA, navigate to File > Project Structure > Project, and set the Project SDK to your newly installed JDK 8.
- Trigger a Gradle sync again—this time it should complete without the version detection error.
内容的提问来源于stack exchange,提问作者Jack Wilson




