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

已回答

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.

2

Try to logout and login again.

0

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

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

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

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

Yes. It is needed to reload environment variables. 

 

1

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

0

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

0

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

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

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

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

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

What's the value of JAVA_HOME?

0

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

0

Value of JAVA_HOME is set to Android Studio /Applications/Android Studio.app/Contents/jbr/Contents/Home and breaking stuff in IntelliJ. How to fix it?

0

Hi Dominic Tobias 

What version of the IDE do you use?

What does echo $JAVA_HOME return if you run it 1) in OS terminal and 2) in IDE terminal?

Does it make a difference if you run export JAVA_HOME=path/to/your/java from the IDE terminal?

0

请先登录再写评论。