先安装git bash
无脑下一步就行。
按照sdkman文档介绍,要么就是WSL,要么就是用git bash,我用git bash,很简单。
安装sdkman
我参考一篇文章安装成功了,重新安装试试。
别忘了下载zip复制到git的指定目录
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
$ curl -s "https://get.sdkman.io" | bash
-+syyyyyyys:
`/yho:` -yd.
`/yh/` +m.
.oho. hy .`
.sh/` :N` `-/o` `+dyyo:.
.yh:` `M- `-/osysoym :hs` `-+sys: hhyssssssssy+
.sh:` `N: ms/-`` yy.yh- -hy. `.N-````````+N.
`od/` `N- -/oM- ddd+` `sd: hNNm -N:
:do` .M. dMMM- `ms. /d+` `NMMs `do
.yy- :N` ```mMMM. - -hy. /MMM: yh
`+d+` `:/oo/` `-/osyh/ossssssdNMM` .sh: yMMN` /m.
-dh- :ymNMMMMy `-/shmNm-`:N/-.`` `.sN /N- `NMMy .m/
`oNs` -hysosmMMMMydmNmds+-.:ohm : sd` :MMM/ yy
.hN+ /d: -MMMmhs/-.` .MMMh .ss+- `yy` sMMN` :N.
:mN/ `N/ `o/-` :MMMo +MMMN- .` `ds mMMh do
/NN/ `N+....--:/+oooosooo+:sMMM: hMMMM: `my .m+ -MMM+ :N.
/NMo -+ooooo+/:-....`...:+hNMN. `NMMMd` .MM/ -m: oMMN. hs
-NMd` :mm -MMMm- .s/ -MMm. /m- mMMd -N.
`mMM/ .- /MMh. -dMo -MMMy od. .MMMs..---yh
+MMM. sNo`.sNMM+ :MMMM/ sh`+MMMNmNm+++-
mMMM- /--ohmMMM+ :MMMMm. `hyymmmdddo
MMMMh. ```` `-+yy/`yMMM/ :MMMMMy -sm:.``..-:-.`
dMMMMmo-.``````..-:/osyhddddho. `+shdh+. hMMM: :MmMMMM/ ./yy/` `:sys+/+sh/
.dMMMMMMmdddddmmNMMMNNNNNMMMMMs sNdo- dMMM- `-/yd/MMMMm-:sy+. :hs- /N`
`/ymNNNNNNNmmdys+/::----/dMMm: +m- mMMM+ohmo/.` sMMMMdo- .om: `sh
`.-----+/.` `.-+hh/` `od. NMMNmds/ `mmy:` +mMy `:yy.
/moyso+//+ossso:. .yy` `dy+:` .. :MMMN+---/oys:
/+m: `.-:::-` /d+ +MMMMMMMNh:`
+MN/ -yh. `+hddhy+.
/MM+ .sh:
:NMo -sh/
-NMs `/yy:
.NMy `:sh+.
`mMm` ./yds-
`dMMMmyo:-.````.-:oymNy:`
+NMMMMMMMMMMMMMMMMms:`
-+shmNMMMNmdy+:`
Now attempting installation...
Looking for a previous installation of SDKMAN...
Looking for unzip...
Looking for zip...
Looking for curl...
Looking for sed...
Installing SDKMAN scripts...
Create distribution directories...
Getting available candidates...
Prime platform file...
Prime the config file...
Installing script cli archive...
* Downloading...
######################################################################## 100.0%
* Checking archive integrity...
* Extracting archive...
* Copying archive contents...
* Cleaning up...
Installing script cli archive...
* Downloading...
######################################################################## 100.0%
* Checking archive integrity...
* Extracting archive...
* Copying archive contents...
* Cleaning up...
Set version to 5.18.2 ...
Set native version to 0.4.6 ...
Attempt update of interactive bash profile on regular UNIX...
Added sdkman init snippet to /c/Users/mahaiqiang/.bashrc
Attempt update of zsh profile...
Updated existing /c/Users/mahaiqiang/.zshrc
All done!
You are subscribed to the STABLE channel.
Please open a new terminal, or run the following in the existing one:
source "/c/Users/mahaiqiang/.sdkman/bin/sdkman-init.sh"
Then issue the following command:
sdk help
Enjoy!!!
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
配置环境变量
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
$ source "$HOME/.sdkman/bin/sdkman-init.sh"
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
$ sdk version
SDKMAN!
script: 5.18.2
native: 0.4.6
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
$ sdk help
NAME
sdk - The command line interface (CLI) for SDKMAN!
SYNOPSIS
sdk <subcommand> [candidate] [version]
DESCRIPTION
SDKMAN! is a tool for managing parallel versions of multiple JVM related
Software Development Kits on most Unix based systems. It provides a
convenient Command Line Interface (CLI) and API for installing, switching,
removing and listing Candidates.
SUBCOMMANDS & QUALIFIERS
help [subcommand]
install <candidate> [version] [path]
uninstall <candidate> <version>
list [candidate]
use <candidate> <version>
config no qualifier
default <candidate> [version]
home <candidate> <version>
env [init|install|clear]
current [candidate]
upgrade [candidate]
version no qualifier
offline [enable|disable]
selfupdate [force]
update no qualifier
flush [tmp|metadata|version]
EXAMPLES
sdk install java 17.0.0-tem
sdk help install
mahaiqiang@DESKTOP-TH3LOPH MINGW64 /
$
安装两个版本jdk
# 安装个java11
sdk install java 11.0.24-zulu
# 安装java22
sdk install java 22.0.2-zulu
切换版本
# 切换版本
sdk use java 11.0.24-zulu
# 设置默认版本
sdk default java 11.0.24-zulu
其他
- 支持的命令参考官方文档