Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij Idea: Importing Gradle project - getting JAVA_HOME not defined yet

Intellij Idea 14.1.4 Mac OS X Yosemite 10.10.3 and later.

From the IDE:

Import Project -> (Chosen directory to import) -> Import project from external model, Gradle -> Gradle Home: /usr/local/Cellar/gradle/2.4/libexec Gradle JVM: Use JAVA_HOME (not defined yet) 

From shell:

echo $JAVA_HOME  /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home 

(defined in .profile: export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

What am I missing. I have checked other discussions in SO, for example, Intellij JAVA_HOME variable, but don't have Project SDK prompt.

like image 725
bentobox Avatar asked Jul 03 '15 23:07

bentobox


2 Answers

You need to setup a SDK for Java projects, like @rizzletang said, but you don't need to create a new project, you can do it from the Welcome screen.

On the bottom right, select Configure > Project Defaults > Project Structure: enter image description here

Picking the Project tab on the left will show that you have no SDK selected:

enter image description here

Just click the New... button on the right hand side of the dropdown and point it to your JDK. After that, you can go back to the import screen and it should just show up.

like image 167
visola Avatar answered Sep 28 '22 21:09

visola


If you'd like to have your JAVA_HOME recognised by intellij, you can do one of these:

  • Start your intellij from terminal /Applications/IntelliJ IDEA 14.app/Contents/MacOS (this will pick your bash env variables)
  • Add login env variable by executing: launchctl setenv JAVA_HOME "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home"

As others have answered you can ignore JAVA_HOME by setting up SDK in project structure.

like image 24
gk0 Avatar answered Sep 28 '22 22:09

gk0