首先请确保已经安装了 Windows 中的软件包管理器: Scoop
scoop reset 命令
如果需要在同一台计算机上运行 Java、Ruby 或 Python 的多个版本,则可以使用scoop reset
在不同版本之间进行切换。
scoop reset
将 re-installs 应用程序的 shims ,并根据应用程序的 manifest 更新 PATH
环境变量。
安装和切换 Java(JDK)
命令格式为:
1
|
scoop reset <java>[@<version>]
|
安装和切换不同的 Java (JDK)版本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
$ scoop bucket add java
$ scoop install oraclejdk
Installing 'oraclejdk' (12.0.2-10) [64bit]
$ scoop install zulu6
Installing 'zulu6' (6.18.1.5) [64bit]
$ scoop install openjdk10
Installing 'openjdk10' (10.0.1) [64bit]
$ java -version
openjdk version "10.0.1" 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10)
OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)
$ scoop reset zulu6
Resetting zulu6 (6.18.1.5).
Linking ~\scoop\apps\zulu6\current => ~\scoop\apps\zulu6\6.18.1.5
$ java -version
openjdk version "1.6.0-99"
OpenJDK Runtime Environment (Zulu 6.18.1.5-win64) (build 1.6.0-99-b99)
OpenJDK 64-Bit Server VM (Zulu 6.18.1.5-win64) (build 23.77-b99, mixed mode)
$ scoop reset oraclejdk
$ java -version
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
|
Python
1
2
3
4
5
6
7
8
9
10
11
12
|
$ scoop bucket add versions # add the 'versions' bucket if you haven't already
$ scoop install python27 python
python --version # -> Python 3.6.2
# switch to python 2.7.x
$ scoop reset python27
python --version # -> Python 2.7.13
# switch back (to 3.x)
$ scoop reset python
python --version # -> Python 3.6.2
|
Ruby 的版本
1
2
3
4
5
6
7
8
9
10
11
12
|
$ scoop bucket add versions # add the 'versions' bucket if you haven't already
$ scoop install ruby ruby19
ruby --version # -> ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
# switch to ruby 2.x
$ scoop reset ruby
ruby --version # -> ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]
# switch back to 1.9.x
$ scoop reset ruby19
ruby --version # -> ruby 1.9.3p551 (2014-11-13) [i386-mingw32]
|