javagradleintellij-ideabuildjava-home

"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.


Solution

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