简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM