Terminal inside IntelliJ is not picking up latest JAVA_HOME variable value after Java update.

Answered

After automatic Java Update of my windows system, I changed my JAVA_HOME and PATH environement variables to point to valid Java installation but the same is not reflected in the terminal inside intellij which is pointing to cmd.exe.


The issue doesn't disappear after restart.
Please help.

15 comments
Comment actions Permalink

Try to logout and login again.

0
Comment actions Permalink

Hello Serge,

I would like to switch between java versions (OSX) back and forth. I expect that it shall be enough to set the jdk version in "Project Settings" -> "Project SDK". This approach does not work in Ultimate 2020.2. Both JAVA_HOME env var and java version in IntelliJ console are unaffected by what is set in "Project Settings".

 

What is the correct approach?

 

Best regards,

Anatoly

 

0
Comment actions Permalink

Project JDK doesn't affect Terminal tool window environment. The only way to change it is via your system environment settings: https://stackoverflow.com/a/26586170/104891.

0
Comment actions Permalink

I'm facing the same under IntelliJ IDEA 2020.3 (Ultimate Edition).

What does it mean "Try to logout and login again" ?

Does it mean to try to sign out your os user account? 

 

0
Comment actions Permalink

> Does it mean to try to sign out your os user account? 

Yes. It is needed to reload environment variables. 

 

1
Comment actions Permalink

In my case on Ubuntu it didn't help. Finally, I set the variable from the terminal inside IntelliJ and it worked.

0
Comment actions Permalink

Prussaq How did you set it in Ubuntu so that IDE didn't pick it up?

0
Comment actions Permalink

Serge Baranov Sorry, I did it wrong, not in /etc/profile. So after logout/login it didn't work. I think the thread can be deleted. Thank you!

0
Comment actions Permalink

Having similar issue. I am on Windows. I have X projects open and switch JAVA_HOME version: PC -> Advanced system settings -> Environment Variables.

Few weeks ago it worked as expected. I close terminal inside project and when I open it again: java -version, showed correct version. Recently it doesn't work that way anymore. It seems like it is unable to close active terminal session.

1
Comment actions Permalink

Jevgeni Serkin Environment is inherited from the parent process. When you change the environment variable, you need to reboot or logout/login for all the processes to update it.

0
Comment actions Permalink

I am having the same issue. Switching to java 17 works fine but when I switch to java 8 I get the message that it is not defined correctly. Tried logout/login and it didn't work.

0
Comment actions Permalink

Semko Developer what exact error do you get? Please provide the screenshots showing the error text and the value of JAVA_HOME environment variable printed in the terminal.

0
Comment actions Permalink

This is what I get

0
Comment actions Permalink

What's the value of JAVA_HOME?

0
Comment actions Permalink

I have fixed it, it was issue with my variable for java 8.

0

Please sign in to leave a comment.