简介
官网:https://github.com/shyiko/jabba
安装
macOS / Linux
https://github.com/shyiko/jabba?tab=readme-ov-file#macos–linux
Windows
powershell
1
2
3
4
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression (
Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing
).Content
|
卸载
1
|
Remove-Item "$env:USERPROFILE\.jabba" -Recurse -Force -ErrorAction SilentlyContinue
|
使用
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# list available JDK's
jabba ls-remote
# you can use any valid semver range to narrow down the list
jabba ls-remote zulu@~1.8.60
jabba ls-remote "*@>=1.6.45 <1.9" --latest=minor
# install Oracle JDK
jabba install 1.15.0
# install Oracle Server JRE
jabba install sjre@1.8
# install Adopt OpenJDK (Hotspot)
jabba install adopt@1.8-0
# install Adopt OpenJDK (Eclipse OpenJ9)
jabba install adopt-openj9@1.9-0
# install Zulu OpenJDK
jabba install zulu@1.8
jabba install zulu@~1.8.144 # same as "zulu@>=1.8.144 <1.9"
# install IBM SDK, Java Technology Edition
jabba install ibm@1.8
# install GraalVM CE
jabba install graalvm@1.0-0
# install OpenJDK
jabba install openjdk@1.10-0
# install OpenJDK with Shenandoah GC
jabba install openjdk-shenandoah@1.10-0
# install from custom URL
# (supported qualifiers: zip (since 0.3.0), tgz, tgx (since 0.10.0), dmg, bin, exe)
jabba install 1.8.0-custom=tgz+http://example.com/distribution.tar.gz
jabba install 1.8.0-custom=tgx+http://example.com/distribution.tar.xz
jabba install 1.8.0-custom=zip+file:///opt/distribution.zip
# uninstall JDK
jabba uninstall zulu@1.6.77
# link system JDK
jabba link system@1.8.72 /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk
# list all installed JDK's
jabba ls
# switch to a different version of JDK (it must be already `install`ed)
jabba use adopt@1.8
jabba use zulu@~1.6.97
echo "1.8" > .jabbarc
# switch to the JDK specified in .jabbarc (since 0.5.0)
jabba use
# set default java version on shell (since 0.2.0)
# this version will automatically be "jabba use"d every time you open up a new terminal
jabba alias default 1.8
|
附录
jabba ls-remote 失败?
出现
1
|
Get https://github.com/shyiko/jabba/raw/master/index.json: net/http: TLS handshake timeout
|
需要设置代理,端口设置为自己代理所在的端口
windows terminal:
1
|
$Env:http_proxy="http://127.0.0.1:10808";$Env:https_proxy="http://127.0.0.1:10808"
|
cmd:
1
|
set http_proxy=http://127.0.0.1:10808 & set https_proxy=http://127.0.0.1:10808
|
如果链接不稳定,下载还是失败,可以尝试这样
1
|
jabba install graalvm-ce-java8@21.0.0=tgz+https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.0.0.2/graalvm-ce-java8-windows-amd64-21.0.0.2.zip
|