Home » Java » kotlin – Terminal in Intellij IDEA does not have JAVA_HOME and java command-Exceptionshub

kotlin – Terminal in Intellij IDEA does not have JAVA_HOME and java command-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I have my command prompt (cmd) and it does show everything even if I go to the same path i’m in Intellij, but in Intellij java command and JAVA_HOME environment variable isn’t set.

I have set environment variables in system as well as in user settings (Win 10)

Here is output of terminal from intellij:

D:\IdeaProjects\(Project)>java -version
'java' is not recognized as an internal or external command,
operable program or batch file.


D:\IdeaProjects\AirbentPluginIF>gradlew dokka

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

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

While output of cmd:

D:\IdeaProjects\AirbentPluginIF>java -version
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)


D:\IdeaProjects\AirbentPluginIF>gradlew dokka
Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details

> Task :dokka
... (more stuffs)

What could be the reason for this?

How to&Answers:

In Environment Variables under Preferences/Tools/Terminal, try setting the value as:

JAVA_HOME=path to your java home

enter image description here