0
votes

echo $JAVA_HOME gives me:

/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home

But trying to import a project to Intellij with this setting doesn't work. Does my JAVA HOME have to be in

/usr/libexec/java_home

if so, how do I make it so with what I currently have?

output of "/usr/libexec/java_home -V"

Matching Java Virtual Machines (4): 1.8.0_73, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home 1.7.0_80, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home 1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-466.1, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home

1
show contents of /usr/libexec/java_home -Vmschr
looks ok to me, though im no mac-user. if such a file exists, your golden; /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/javac. For each project you can add an SDK. Load the project and go into Project Structure > Project > Project SDK - and define a New one for use, if nescessarymschr
@mschr though when trying to import my project it says "JAVA_HOME environmental variable not defined"Benni

1 Answers

3
votes

3 things apply to your ENV variables in which JAVA_HOME should be. ENV is a scoped 'dictionary' which is instantiated/loaded with every process being started on an OS.

It is generally loaded through SYSTEM config and USER config. The files residing in /etc are considered SYSTEM - and for OSX the following applies; last loaded file will overwrite previous values:

Login shell

First /etc/profile, then whichever of the following exists, trying them in order: ~/.bash_profile, ~/.bash_login, or ~/.profile

Non-login shell

/etc/bashrc, then ~/.bashrc

THEN if the script, that actually loads IntelliJ has a mechanism for setting ENV variables, this will of course be one with the last 'word'.

For IntelliJ i believe a specific variable is used for this purpose, namely IDEA_SDK. So add the following to both ~/.profile and ~/.bashrc for your USER:

export IDEA_SDK=$(/usr/libexec/java_home -v 1.8.0_73)

Hope this works (make sure the command is just right - mby even just leave out the version arguments)