java内嵌命令行,在MacOS的命令行中使用Android Studio的内置Java

There's lots of info here (much obsolete) on installing Java on the mac, and getting Android Studio to use the right versions.

But recent builds of Android Studio (2.2 and on?) provide their own Java, and for most Mac users, there's just no reason (or desire) to install a browser or command line Java anymore ... until you want to use any of the Studio's shell tools, and realize they're all in java, and the studio's Java is not integrated into the wonder that is java_home.

Obviously, your path vars need to be updated to include the Android SDK, and JAVA_HOME and JDK_HOME need to be set, but the actual details of doing so are thin on the ground.

So ... what are the correct paths and settings needed to simply use the Studio's embedded java and android tools in MacOS shells, instead of installing extra Java instances from Oracle?

解决方案

Add this to your ~/.profile or similar:

# Use the JDK embedded with Android Studio for command-line builds

export JAVA_HOME='/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home'

Command-line builds via gradlew, and any other well-behaved script, will then use the version of the SDK that ships with Android Studio 2.2+.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值