使用sdkman快速安装和管理多版本Java sdk

  • A+
所属分类:Java linux

官网

https://sdkman.io/

安装

curl -s "https://get.sdkman.io" | bash
source "/root/.sdkman/bin/sdkman-init.sh"

显示结果如下,即已安装成功

[email protected]:~# 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 the config file...
Download script archive...
######################################################################## 100.0%
Extract script archive...
Install scripts...
Set version to 5.9.2+613 ...
Attempt update of interactive bash profile on regular UNIX...
Added sdkman init snippet to /root/.bashrc
Attempt update of zsh profile...
Updated existing /root/.zshrc

All done!

Please open a new terminal, or run the following in the existing one:

    source "/root/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
[email protected]:~# source "/root/.sdkman/bin/sdkman-init.sh"

列出可安装的java sdk版本

sdk ls java

显示结果如下

================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 15.0.1.j9    | adpt    |            | 15.0.1.j9-adpt      
               |     | 15.0.1.hs    | adpt    |            | 15.0.1.hs-adpt      
               |     | 14.0.2.j9    | adpt    |            | 14.0.2.j9-adpt      
               |     | 14.0.2.hs    | adpt    |            | 14.0.2.hs-adpt      
               |     | 13.0.2.j9    | adpt    |            | 13.0.2.j9-adpt      
               |     | 13.0.2.hs    | adpt    |            | 13.0.2.hs-adpt      
               |     | 12.0.2.j9    | adpt    |            | 12.0.2.j9-adpt      
               |     | 12.0.2.hs    | adpt    |            | 12.0.2.hs-adpt      
               |     | 11.0.9.open  | adpt    |            | 11.0.9.open-adpt    
               |     | 11.0.9.j9    | adpt    |            | 11.0.9.j9-adpt      
               |     | 11.0.9.hs    | adpt    |            | 11.0.9.hs-adpt      
               |     | 8.0.275.open | adpt    |            | 8.0.275.open-adpt   
               |     | 8.0.275.j9   | adpt    |            | 8.0.275.j9-adpt     
               |     | 8.0.275.hs   | adpt    |            | 8.0.275.hs-adpt     
 Alibaba       |     | 11.0.9.4     | albba   |            | 11.0.9.4-albba      
               |     | 11.0.8       | albba   |            | 11.0.8-albba        
               |     | 8u272        | albba   |            | 8u272-albba         
               |     | 8.5.5        | albba   |            | 8.5.5-albba         
 Amazon        |     | 15.0.1       | amzn    |            | 15.0.1-amzn         
               |     | 11.0.9       | amzn    |            | 11.0.9-amzn         
               |     | 8.0.275      | amzn    |            | 8.0.275-amzn        
 Azul Zulu     |     | 15.0.1       | zulu    |            | 15.0.1-zulu         
               |     | 15.0.1.fx    | zulu    |            | 15.0.1.fx-zulu      
               |     | 14.0.2       | zulu    |            | 14.0.2-zulu         
               |     | 14.0.2.fx    | zulu    |            | 14.0.2.fx-zulu      
               |     | 13.0.5       | zulu    |            | 13.0.5-zulu         
               |     | 13.0.5.fx    | zulu    |            | 13.0.5.fx-zulu      
               |     | 12.0.2       | zulu    |            | 12.0.2-zulu         
               |     | 11.0.9       | zulu    |            | 11.0.9-zulu         
               |     | 11.0.9.fx    | zulu    |            | 11.0.9.fx-zulu      
               |     | 10.0.2       | zulu    |            | 10.0.2-zulu         
               |     | 9.0.7        | zulu    |            | 9.0.7-zulu          
               |     | 8.0.275      | zulu    |            | 8.0.275-zulu        
               |     | 8.0.275.fx   | zulu    |            | 8.0.275.fx-zulu     
               |     | 7.0.282      | zulu    |            | 7.0.282-zulu        
               |     | 6.0.119      | zulu    |            | 6.0.119-zulu        
 BellSoft      |     | 15.0.1.fx    | librca  |            | 15.0.1.fx-librca    
               |     | 15.0.1       | librca  |            | 15.0.1-librca       
               |     | 14.0.2.fx    | librca  |            | 14.0.2.fx-librca    
               |     | 14.0.2       | librca  |            | 14.0.2-librca       
               |     | 13.0.2.fx    | librca  |            | 13.0.2.fx-librca    
               |     | 13.0.2       | librca  |            | 13.0.2-librca       
               |     | 12.0.2       | librca  |            | 12.0.2-librca       
               |     | 11.0.9.fx    | librca  |            | 11.0.9.fx-librca    
               |     | 11.0.9       | librca  |            | 11.0.9-librca       
               |     | 8.0.275.fx   | librca  |            | 8.0.275.fx-librca   
               |     | 8.0.275      | librca  |            | 8.0.275-librca      
 GraalVM       |     | 20.3.0.r11   | grl     |            | 20.3.0.r11-grl      
               |     | 20.3.0.r8    | grl     |            | 20.3.0.r8-grl       
 Java.net      |     | 17.ea.5      | open    |            | 17.ea.5-open        
               |     | 17.ea.2.lm   | open    |            | 17.ea.2.lm-open     
               |     | 16.ea.32     | open    |            | 16.ea.32-open       
               |     | 16.ea.3.pma  | open    |            | 16.ea.3.pma-open    
               |     | 15.0.1       | open    |            | 15.0.1-open         
               |     | 14.0.2       | open    |            | 14.0.2-open         
               |     | 13.0.2       | open    |            | 13.0.2-open         
               |     | 12.0.2       | open    |            | 12.0.2-open         
               |     | 11.0.2       | open    |            | 11.0.2-open         
               |     | 10.0.2       | open    |            | 10.0.2-open         
               |     | 9.0.4        | open    |            | 9.0.4-open          
               |     | 8.0.265      | open    |            | 8.0.265-open        
 Mandrel       |     | 20.2.0.0     | mandrel |            | 20.2.0.0-mandrel    
               |     | 20.1.0.3     | mandrel |            | 20.1.0.3-mandrel    
 SAP           |     | 15.0.1       | sapmchn |            | 15.0.1-sapmchn      
               |     | 14.0.2       | sapmchn |            | 14.0.2-sapmchn      
               |     | 13.0.2       | sapmchn |            | 13.0.2-sapmchn      
               |     | 12.0.2       | sapmchn |            | 12.0.2-sapmchn      
               |     | 11.0.9       | sapmchn |            | 11.0.9-sapmchn      
 TravaOpenJDK  |     | 11.0.9       | trava   |            | 11.0.9-trava        
               |     | 8.0.232      | trava   |            | 8.0.232-trava       
================================================================================
Use the Identifier for installation:

    $ sdk install java 11.0.3.hs-adpt
================================================================================

安装java 8

sdk install java 8.0.275.hs-adpt

显示如下,说明已经安装成功。

[email protected]:~# sdk install java 8.0.275.hs-adpt

Downloading: java 8.0.275.hs-adpt

In progress...

#################################################################################################################################################### 100.0%#################################################################################################################################################### 100.0%

Repackaging Java 8.0.275.hs-adpt...

Done repackaging...

Installing: java 8.0.275.hs-adpt
Done installing!

Do you want java 8.0.275.hs-adpt to be set as default? (Y/n): y

Setting java 8.0.275.hs-adpt as default.
[email protected]:~# 

查看Java版本

java -version

显示如下,说明安装成功

[email protected]:~# java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.275-b01, mixed mode)
[email protected]:~# 
若链接失效,请在评论区评论留言
头像

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: