Intellij Gradle终端错误:未设置JAVA_HOME [英] Intellij Gradle terminal ERROR: JAVA_HOME is not set
问题描述
在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屋!