Search code examples
javaintellij-idea

IntelliJ terminal has a different environment path?


I am trying to run maven project in the intelliJ, then got an error

 JAVA_HOME is set to an invalid directory.
 JAVA_HOME = "H:\jdk\1.8\bin"
 Please set the JAVA_HOME varialbe in your environment to match 
 the location of you Java installation

I have changed the environment variable in system to "H:\jdk\1.8", and restart the intelliJ, still got the same error. But in system command prompt, the java_home is already "H:\jdk\1.8"

Does anyone know how to solve it? Thank you.


Solution

  • Environment variables are inherited from the parent process and are not updated on the fly in most cases. You should logout/login or reboot for the environment variables to have effect for all the apps on the system.