Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij JAVA_HOME variable

I started using Gradle and Intellij but I am having problems to configure Gradle's JVM. When I start a new Gradle project I am not allowed to define JVM as my JAVA_HOME variable. The following screenshots show what is happening:

new gradle project

As you can see Intellij says that my JAVA_HOME variable is not defined, however if I type echo $JAVA_HOME I can get my Java directory, in my case: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

My ./~bash_profile is configured as follow: export JAVA_HOME=$(/usr/libexec/java_home)

Someone can figure what is happening ? Thank you!

like image 474
user2568889 Avatar asked Jun 21 '15 00:06

user2568889


People also ask

How do I set JAVA_HOME variable?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.

Can I set JAVA_HOME in user variable?

Click Environment variables. Under User variables, click New. Enter JAVA_HOME as the variable name. Enter the path to the JDK as the variable value.

What is the JAVA_HOME variable?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.


1 Answers

Bit counter-intuitive, but you must first setup a SDK for Java projects. On the bottom right of the IntelliJ welcome screen, select 'Configure > Project Defaults > Project Structure'.

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

Therefore, you must 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 be populated with your JAVA_HOME variable, providing you have this set.

like image 189
RMcGuigan Avatar answered Sep 22 '22 19:09

RMcGuigan