Intellij Gradle 终端错误:未设置 JAVA_HOME [英] Intellij Gradle terminal ERROR: JAVA_HOME is not set

查看:56
本文介绍了Intellij Gradle 终端错误:未设置 JAVA_HOME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 IntelliJ IDEA 中,使用 Gradle 窗口我可以执行任何和所有 Gradle 任务.但是,当我尝试通过 IDE 中的终端窗口执行相同的任务时,出现以下错误:

In IntelliJ IDEA, using the Gradle window I am able to execute any and all Gradle tasks. However, when I try and execute the same tasks through the terminal window within the IDE, it hits me with the following error:

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.

使用 gradle 和 gradlew 时会出现这种情况.在 IntelliJ -> 文件 -> 项目结构 -> 项目中,SDK 正确设置为 1.8.任何解决此问题的建议,以便我可以使用终端执行 Gradle 任务,将不胜感激.

This occurs when using gradle and gradlew. In IntelliJ -> File -> Project Structure -> Project then SDK is set correctly to 1.8. Any suggestions for resolving this so I can use the terminal to execute Gradle tasks would be greatly appreciated.

推荐答案

您需要一个环境变量集才能工作.您可以简单地在命令行中输入:

You need an environment variable set for this to work. You can simply type in the command line:

export JAVA_HOME=<PATH to your Java Home>

或者您可以将该行放在您的 .rc 文件中.在 Mac 上,您可以这样做:

Or you can put that line in your .rc file. On a mac you can do this:

export JAVA_HOME=`/usr/libexec/java_home`

可以在此处找到更多信息:http://javarevisited.blogspot.com/2012/02/how-to-set-javahome-environment-in.html

More information can be found here: http://javarevisited.blogspot.com/2012/02/how-to-set-javahome-environment-in.html

这篇关于Intellij Gradle 终端错误:未设置 JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆