“Java home is different.”在Intelij上构建Gradle项目时。

huangapple go评论64阅读模式
英文:

"Java home is different." when building gradle project on Intelij

问题

I tried to import a gradle project on InteliJ but I get this error when it's building:

`Java home is different. Expecting: 'C:\Program Files\Java\jdk-1.8'
but was: 'C:\Program Files\Java\jdk-1.8\jre'.

Please configure the JDK to match the expected one.

Open JDK Settings`

I understand this error BUT, when i change my JAVA_HOME nothing happened !!! Even if I use SDK 17, the error still " jdk-1.8......". Each time I change JAVA_HOME I check my "java -version".

In case, I give my parameters:

JAVA_HOME:
echo %JAVA_HOME% C:\Program Files\Java\jdk-1.8

My Path :
echo %Path% C:\Program Files\Java\jdk-1.8\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\Program Files (x86)\Common Files\Pulse Secure\TNC Client Plugin\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X86\;C:\Users\a904778\Downloads\apache-ant-1.9.16-bin\apache-ant-1.9.16\bin;C:\Users\a904778\Downloads\apache-ant-1.9.16-bin\apache-ant-1.9.16\bin;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Users\a904778\AppData\Local\Microsoft\WindowsApps;C:\Users\a904778\Downloads\gradle-3.0-bin\gradle-3.0\bin;

PS: I even tried to unistall/ install InteliJ but same error.

I checked ALL the forum before and nothing worked.

英文:

I tried to import a gradle project on InteliJ but I get this error when it's building :

> Java home is different. Expecting: 'C:\Program Files\Java\jdk-1.8'
> but was: 'C:\Program Files\Java\jdk-1.8\jre'.
>
> Please configure the JDK to match the expected one.
>
> Open JDK Settings

I understand this error BUT, when i change my JAVA_HOME nothing happened !!! Even if I use SDK 17, the error still " jdk-1.8......". Each time I change JAVA_HOME I check my "java -version".

In case, I give my parameters:

JAVA_HOME:
echo %JAVA_HOME%
C:\Program Files\Java\jdk-1.8

My Path :
echo %Path%
C:\Program Files\Java\jdk-1.8\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Pulse Secure\VC142.CRT\X86\;C:\Program Files (x86)\Common Files\Pulse Secure\TNC Client Plugin\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X64\;C:\Program Files (x86)\Common Files\Pulse Secure\VC142.CRT\X86\;C:\Users\a904778\Downloads\apache-ant-1.9.16-bin\apache-ant-1.9.16\bin;C:\Users\a904778\Downloads\apache-ant-1.9.16-bin\apache-ant-1.9.16\bin;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Users\a904778\AppData\Local\Microsoft\WindowsApps;C:\Users\a904778\Downloads\gradle-3.0-bin\gradle-3.0\bin;

PS: I even tried to unistall/ install InteliJ but same error.

I checked ALL the forum before and nothing worked.

答案1

得分: 0

以下是翻译好的部分:

"OK actually to fix this I just uninstalled all java installations (even in programfiles/java) and reinstalled intellij/java and it worked."

英文:

OK actually to fix this I just unistalled all java instalations (even in programfiles/java) and re install intellij/java and it worked.

huangapple
  • 本文由 发表于 2023年6月12日 22:01:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76457418.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定