mac上安装jenv(Java版本控制工具)

1 . 安装homebrew(默认您没安装).

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

2 . 安装jenv

brew install jenv.

3 . 设置环境变量

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

4 . 检查是否安装成功

jenv.

5 .显示如下表示安装成功

jenv 0.4.4
Usage: jenv []
Some useful jenv commands are:
commands List all available jenv commands
local Set or show the local application-specific Java version
global Set or show the global Java version
shell Set or show the shell-specific Java version
rehash Rehash jenv shims (run this after installing executables)
version Show the current Java version and its origin
versions List all Java versions available to jenv
which Display the full path to an executable
whence List all Java versions that contain the given executable
See `jenv help ' for information on a specific command.
For full documentation, see: https://github.com/hikage/jenv#readme
```.
6 .添加jdk,如有多个添加多次
`jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/`.

7 .添加成功后显示

`oracle64-1.7.0.80 added

1.7.0.80 added

1.7 added`.

8 .切换版本

`jenv local 1.8`.

9 .移除jdk

先查询`jenv versions`

再移除`jenv remove 1.8`