whiterook6
whiterook6

Reputation: 3544

After installing java8 via Homebrew, JAVA_HOME is incorrect

I am installing the android sdk on my mac via homebrew. First I ran

brew cask install android-sdk

and it told me to install java8 as well:

brew cask install homebrew/cask-versions/java8

Now, when I try to run the sdkmanager, I get this error:

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

Obviously I have to edit JAVA_HOME in my .bash_profile file. Where should it point?

Every question I've found on SO and other sites simply says to "Point to the JDK, not the JRE." Also I can find default java installation directories from oracle guides, etc. But nothing about java8 from homebrew.

Upvotes: 2

Views: 5245

Answers (1)

Elliott Frisch
Elliott Frisch

Reputation: 201447

I usually use sdkman, but I installed this cask so I could answer:

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

So you can do that, or in sdkman, you could use

sdk install java 8.0.181-oracle

and then either set it as the default there or issue a

sdk use java 8.0.181-oracle

or whatever java you need (like sdk use java 10.0.1-oracle) for the session.

Upvotes: 3

Related Questions