쩨이엠 개발 블로그

[ java ] sdkman으로 자바 버전 관리하기 본문

개발/JAVA

[ java ] sdkman으로 자바 버전 관리하기

쩨이엠 2020. 10. 17. 16:09
728x90
반응형

 

계속 java를 1.8버전을 쓰다가 11버전도 써야하는 상황이 발생했다

java 버전 관리를 좀더 쉽게 할 수 있는걸 찾던중 sdkman을 발견했다

 

sdkman 설치

 
 $ 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.1+575 ...
Attempt update of login bash profile on OSX...
Added sdkman init snippet to /Users/1100610/.bash_profile
Attempt update of zsh profile...
Updated existing /Users/1100610/.zshrc



All done!


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

    source "/Users/1100610/.sdkman/bin/sdkman-init.sh"

Then issue the following command:

    sdk help

Enjoy!!!
$ source "/Users/1100610/.sdkman/bin/sdkman-init.sh"
 

설치가 다 되었으면 sdkman 명령어를 쓰기 위해

$ source "/Users/1100610/.sdkman/bin/sdkman-init.sh" 를 입력한다

 

 

제대로 설치가 되었으면 sdk version으로 sdkman의 버전을 확인 할 수 있다

 $ sdk version

==== BROADCAST =================================================================
* 2020-10-15: jbang 0.52.0 available on SDKMAN! https://git.io/JTs70
* 2020-10-15: vertx 3.9.4 available on SDKMAN!
* 2020-10-14: gradle 6.7 available on SDKMAN!
================================================================================

SDKMAN 5.9.1+575
 

 

 

설치 가능한 java 버전 목록 조회

 
 $ sdk list java
 
================================================================================
Available Java Versions
================================================================================
 Vendor        | Use | Version      | Dist    | Status     | Identifier
--------------------------------------------------------------------------------
 AdoptOpenJDK  |     | 15.0.0.j9    | adpt    |            | 15.0.0.j9-adpt      
               |     | 15.0.0.hs    | adpt    |            | 15.0.0.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.8.j9    | adpt    |            | 11.0.8.j9-adpt      
               |     | 11.0.8.hs    | adpt    |            | 11.0.8.hs-adpt      
               |     | 8.0.265.j9   | adpt    |            | 8.0.265.j9-adpt     
               |     | 8.0.265.hs   | adpt    |            | 8.0.265.hs-adpt     
 Amazon        |     | 15.0.0       | amzn    |            | 15.0.0-amzn         
               |     | 11.0.8       | amzn    |            | 11.0.8-amzn         
               |     | 8.0.265      | amzn    |            | 8.0.265-amzn        
 Azul Zulu     |     | 15.0.0       | zulu    |            | 15.0.0-zulu         
               |     | 15.0.0.fx    | zulu    |            | 15.0.0.fx-zulu      
               |     | 14.0.2       | zulu    |            | 14.0.2-zulu         
               |     | 14.0.2.fx    | zulu    |            | 14.0.2.fx-zulu      
               |     | 13.0.4       | zulu    |            | 13.0.4-zulu         
               |     | 13.0.4.fx    | zulu    |            | 13.0.4.fx-zulu      
               |     | 12.0.2       | zulu    |            | 12.0.2-zulu         
               |     | 11.0.8       | zulu    |            | 11.0.8-zulu         
               |     | 11.0.8.fx    | zulu    |            | 11.0.8.fx-zulu      
               |     | 10.0.2       | zulu    |            | 10.0.2-zulu         
               |     | 9.0.7        | zulu    |            | 9.0.7-zulu          
               |     | 8.0.265      | zulu    |            | 8.0.265-zulu        
               |     | 8.0.265.fx   | zulu    |            | 8.0.265.fx-zulu     
               |     | 8.0.232.fx   | zulu    |            | 8.0.232.fx-zulu     
               |     | 8.0.202      | zulu    |            | 8.0.202-zulu        
               |     | 7.0.262      | zulu    |            | 7.0.262-zulu        
               |     | 7.0.181      | zulu    |            | 7.0.181-zulu        
 BellSoft      |     | 15.0.0.fx    | librca  |            | 15.0.0.fx-librca    
               |     | 15.0.0       | librca  |            | 15.0.0-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.8.fx    | librca  |            | 11.0.8.fx-librca    
               |     | 11.0.8       | librca  |            | 11.0.8-librca       
               |     | 8.0.265.fx   | librca  |            | 8.0.265.fx-librca   
               |     | 8.0.265      | librca  |            | 8.0.265-librca      
 GraalVM       |     | 20.2.0.r11   | grl     |            | 20.2.0.r11-grl      
               |     | 20.2.0.r8    | grl     |            | 20.2.0.r8-grl       
               |     | 20.1.0.r11   | grl     |            | 20.1.0.r11-grl      
               |     | 20.1.0.r8    | grl     |            | 20.1.0.r8-grl       
               |     | 20.0.0.r11   | grl     |            | 20.0.0.r11-grl      
               |     | 20.0.0.r8    | grl     |            | 20.0.0.r8-grl       
               |     | 19.3.1.r11   | grl     |            | 19.3.1.r11-grl      
               |     | 19.3.1.r8    | grl     |            | 19.3.1.r8-grl       
 Java.net      |     | 16.ea.19     | open    |            | 16.ea.19-open       
               |     | 16.ea.6.lm   | open    |            | 16.ea.6.lm-open     
               |     | 16.ea.2.pma  | open    |            | 16.ea.2.pma-open    
               |     | 15           | open    |            | 15-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          
 SAP           |     | 15.0.0       | sapmchn |            | 15.0.0-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.8       | sapmchn |            | 11.0.8-sapmchn      
================================================================================
Use the Identifier for installation:

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

만약 자바가 아닌 다른 프로그램이 필요하다면 java 대신 다른것을 넣으면 된다

리스트 중 필요한 Identifier를 선택하면 된다

내 경우는 11.0.8 version을 선택했다

 

  
 $ sdk install java 11.0.8.j9-adpt  

 Downloading: java 11.0.8.j9-adpt

 In progress...

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

 Repackaging Java 11.0.8.j9-adpt...

 Done repackaging...
 Cleaning up residual files...

 Installing: java 11.0.8.j9-adpt
 Done installing!


 Setting java 11.0.8.j9-adpt as default.
 

 

만약 버전을 선택하지 않는 경우는 latest stable 버전을 자동으로 선택하여 설치해준다

 

 

사용할 버전 지정

 
 $ sdk use java 11.0.8.j9-adpt
  
 Using java version 11.0.8.j9-adpt in this shell.
  

use를 쓰면 현재 터미널에서 사용할 버전이 변경된다

 

Default 버전 지정


 $ sdk default java 11.0.8.j9-adpt
 
 Default java version set to 11.0.8.j9-adpt
  

 

 

제대로 지정되었는지 확인해보기 위해 java -version을 입력하면

11버전으로 변경된 것을 확인할 수 있다

 
 $ java -version
 openjdk version "11.0.8" 2020-07-14
 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
 Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.21.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20200715_677 (JIT enabled, AOT enabled)
 OpenJ9   - 34cf4c075
 OMR      - 113e54219
 JCL      - 95bb504fbb based on jdk-11.0.8+10)
 

 

그 밖에도 사용중인 전체 버전을 확인 할 수 있는 명령어도 있으니 알아두면 편리하게 쓸 수 있겠다

 
 $ sdk current
 
 Using:

 java: 11.0.8.j9-adpt
 

 

728x90
반응형
Comments