markdown MacOS JDK安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown MacOS JDK安装相关的知识,希望对你有一定的参考价值。

After Sierra upgrade, all my JDK were removed. So here is how I reinstalled all of them with only brew commands, and manage them with jEnv.

First do all your mac updates (especially XCode), then:

__Install Brew:__

```
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

__Install JDK 8:__

```
brew cask install java
```

__Install other JDKs:__

```
brew tap caskroom/versions
brew search java
brew cask install java7
brew cask install java6
brew cask install java9-beta
```

__Upgrading__

```
brew update
brew upgrade
```

__Managing your JDKs globally, per shell or per folder with Jenv:__

Website: [http://www.jenv.be/](http://www.jenv.be/)

```
brew install jenv
```

Since I have zsh (see website for bash instructions), I also execute:

```
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc
```

Source your profile again:

```
. ~/.zshrc
```

(for bash, you have to do the equivalent, )

```
. ~/.bash_profile
```

Then add your JDKs:

```
jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
jenv add /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/
...
```

Then switch between them:

List managed JDKs

```
jenv versions
```

outputs:

```
  system
  1.6
  1.6.0.65
  1.7
  1.7.0.79
  1.7.0.80
* 1.8 (set by /Users/matc/.jenv/version)
  1.8.0.112
  9-ea
  oracle64-1.6.0.65
  oracle64-1.7.0.79
  oracle64-1.7.0.80
  oracle64-1.8.0.112
  oracle64-9-ea
```

Configure global version

```
jenv global 1.8
```

Configure local version (per directory)

```
jenv local 1.6
```

Configure shell instance version

```
jenv shell 1.6
```

以上是关于markdown MacOS JDK安装的主要内容,如果未能解决你的问题,请参考以下文章

markdown 安装新鲜的macOS

markdown 在macOS上安装NodeJS和NPM

markdown 使用Homebrew在macOS上安装MySQL 5.7

markdown 在macOS High Sierra上安装多个Java版本

markdown 在macOS High Sierra上安装多个Java版本

markdown 使用nvm为Linux和macOS安装Node.js.