java mac os x,Mac OS X和多个Java版本

在Mac上安装Java 7作为现有Java 8的补充,最干净的方法是使用Homebrew和jenv。首先安装Homebrew,然后通过Homebrew Cask安装所需版本的Java。jenv用于管理不同版本的Java,确保正确设置路径。使用`/usr/libexec/java_home-V`检查已安装版本,并通过jenv添加新版本。
摘要由CSDN通过智能技术生成

How can I install an additional java on MacOS? I installed jdk8 and that works fine. but now I need a jdk7 installation for development purposes. When trying to install the old version via DMG file, i get a warning, that there is already a newer version of java installed and the installer quits.

/usr/libexec/java_home -verbose

Matching Java Virtual Machines (1):

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

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

How to install jdk7 in addition to this one?

Thanks

Dakky

解决方案

The cleanest way to manage multiple java versions on Mac is to use Homebrew.

And within Homebrew, use:

homebrew-cask to install the versions of java

jenv to manage the installed versions of java

install homebrew

install homebrew jenv

install homebrew-cask

install a specific java version using cask (see "homebrew-cask versions" paragraph below)

add this version for jenv to manage it

check the version is correctly managed by jenv

repeat steps 4 to 6 for each version of java you need

homebrew-cask versions

Add the homebrew/cask-versions tap to homebrew using:

brew tap homebrew/cask-versions

Then you can look at all the versions available:

brew search java

Then you can install the version(s) you like:

brew cask install java7

brew cask install java6

And add them to be managed by jenv as usual.

jenv add

I think this is the cleanest & simplest way to go about it.

Another important thing to note, as mentioned in Mac OS X 10.6.7 Java Path Current JDK confusing :

For different types of JDKs or installations, you will have different

paths

You can check the paths of the versions installed using /usr/libexec/java_home -V, see How do I check if the Java JDK is installed on Mac?

On Mac OS X Mavericks, I found as following:

1) Built-in JRE default: /Library/Internet\

Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

2) JDKs downloaded from Apple: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/

3) JDKs downloaded from Oracle: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

Resources

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值