0

I'm on windows and have set the environment JDK for the intelli J project to jdk 1.8 as well as the path for JAVA_HOME in the system variable setting to the jdk 1.8 path however when I try to use "gradle build" in the local terminal in intelli j it tells me

"ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk-10.0.2

Please set the JAVA_HOME variable in your environment to match the location of your Java installation."

When I buil the project in cmd prompt it works fine however I'd like to be able to do it in the local terminal. Is there a command to let me set the path for JAVA_HOME through the intelli j terminal?

Dennis Liu
  • 43
  • 5
  • Have you tried restarting Intellij? An application only picks up environment variables (and changes to them) from the environment when it restart. – Stephen C Mar 19 '19 at 10:24
  • https://stackoverflow.com/questions/17379117/setting-java-home-for-intellij – ebug38 Mar 19 '19 at 10:24
  • In IntelliJ, you can specify which SDK to use at the project level. go to "File" --> "Project Structure" --> SDKs. Add/remove paths to different SDKs – Shravan40 Mar 19 '19 at 10:34
  • Possible duplicate of [How to set java\_home on Windows 7?](https://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7) – Mehraj Malik Mar 19 '19 at 10:44
  • Possible duplicate of [Setting JAVA\_HOME for intelliJ?](https://stackoverflow.com/questions/17379117/setting-java-home-for-intellij) – KevinO Mar 19 '19 at 15:48

1 Answers1

0

You can find it out at Selecting-the-JDK-version-the-IDE-will-run-under

Try also to see the environment variables settings. Go to windows environment variables -> under system variables, seek for the varaible "JAVA_HOME" -> see the value and edit if its wrong path

lolo
  • 17,392
  • 9
  • 25
  • 49