OSX中,安装多个JDK版本

在~/.bash_profile中设置JAVA_HOME

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_91)

可以指定java具体版本。


下面命令可以列出已安装的JDK:

/usr/libexec/java_home -V




username@localhost:~$ /usr/libexec/java_home -h

Usage: java_home [options...]

    Returns the path to a Java home directory from the current user's settings.


Options:

    [-v/--version   <version>]       Filter Java versions in the "JVMVersion" form 1.X(+ or *).

    [-a/--arch      <architecture>]  Filter JVMs matching architecture (i386, x86_64, etc).

    [-d/--datamodel <datamodel>]     Filter JVMs capable of -d32 or -d64

    [-t/--task      <task>]          Use the JVM list for a specific task (Applets, WebStart, BundledApp, JNI, or CommandLine)

    [-F/--failfast]                  Fail when filters return no JVMs, do not continue with default.

    [   --exec      <command> ...]   Execute the $JAVA_HOME/bin/<command> with the remaining arguments.

    [-R/--request]                   Request installation of a Java Runtime if not installed.

    [-X/--xml]                       Print full JVM list and additional data as XML plist.

    [-V/--verbose]                   Print full JVM list with architectures.

    [-h/--help]                      This usage information.

username@localhost:~$ /usr/libexec/java_home -V

Matching Java Virtual Machines (3):

    1.8.0_91, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

    1.8.0_66, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home

    1.7.0_79, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home


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

username@localhost:~$ /usr/libexec/java_home -v 1.8.0_91

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

username@localhost:~$ /usr/libexec/java_home -v 1.7

/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

username@localhost:~











本文转自 h2appy  51CTO博客,原文链接:http://blog.51cto.com/h2appy/1694965,如需转载请自行联系原作者
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值