ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Java 11 설치하기
    24년 11월 이전/ETC 2021. 9. 29. 21:11
    반응형
    $ sudo amazon-linux-extras install java-openjdk11 -y

    개요

    운영 환경은 다음과 같다.

    • OS: CentOS 8 (Virtualbox) / Amazon Linux2

    자바 11 설치 (CentOS 8)

    CentOS 8Yum 레포지토리에는 이미 자바 11에 대한 패키지가 존재한다.

    $ sudo yum search openjdk
    Failed to set locale, defaulting to C.UTF-8
    CentOS Linux 8 - AppStream                                                                                                                                                        1.8 MB/s | 9.3 MB     00:05
    CentOS Linux 8 - BaseOS                                                                                                                                                           2.6 MB/s | 7.5 MB     00:02
    CentOS Linux 8 - Extras                                                                                                                                                            13 kB/s |  10 kB     00:00
    ======================================================================================== Name & Summary Matched: openjdk =========================================================================================
    java-1.8.0-openjdk.x86_64 : OpenJDK 8 Runtime Environment
    java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK 8 accessibility connector
    java-1.8.0-openjdk-demo.x86_64 : OpenJDK 8 Demos
    java-1.8.0-openjdk-devel.x86_64 : OpenJDK 8 Development Environment
    java-1.8.0-openjdk-headless.x86_64 : OpenJDK 8 Headless Runtime Environment
    java-1.8.0-openjdk-headless-slowdebug.x86_64 : OpenJDK 8 Runtime Environment unoptimised with full debugging on
    java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation
    java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in a single archive
    java-1.8.0-openjdk-slowdebug.x86_64 : OpenJDK 8 Runtime Environment unoptimised with full debugging on
    java-1.8.0-openjdk-src.x86_64 : OpenJDK 8 Source Bundle
    java-11-openjdk.x86_64 : OpenJDK 11 Runtime Environment
    java-11-openjdk-demo.x86_64 : OpenJDK 11 Demos
    java-11-openjdk-devel.x86_64 : OpenJDK 11 Development Environment
    java-11-openjdk-headless.x86_64 : OpenJDK 11 Headless Runtime Environment
    java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation
    java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in a single archive
    java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11
    java-11-openjdk-src.x86_64 : OpenJDK 11 Source Bundle
    java-11-openjdk-static-libs.x86_64 : OpenJDK 11 libraries for static linking
    ============================================================================================ Summary Matched: openjdk ============================================================================================
    icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation

     

    따라서 다음 명령어로 간단하게 설치가 가능하다.

    $ sudo yum install java-11-openjdk-devel.x86_64 -y

     

    설치가 완료되면 java --version으로 설치를 확인할 수 있다.

    $ java --version
    openjdk 11.0.12 2021-07-20 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

    자바 11 설치 (Amazon Linux2)

    AWS EC2의 기본 OS인 Amzon Linux2에서는 다음 명령어로 설치할 수 있다.

    $ sudo amazon-linux-extras install java-openjdk11 -y

     

    이제 자바 버전을 확인해보자.

    $ java -version
    openjdk version "1.8.0_302"
    OpenJDK Runtime Environment (build 1.8.0_302-b08)
    OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

     

     

    자바 11은 설치되었으나 아직 환경변수 세팅이 덜 되어서 자바 8을 출력하고 있다. 이를 설정해준다.

    $ sudo alternatives --config java
    
    2 개의 프로그램이 'java'를 제공합니다.
    
      선택    명령
    -----------------------------------------------
    *+ 1           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.amzn2.0.1.x86_64/jre/bin/java)
       2           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.amzn2.0.2.x86_64/bin/java)
    
    현재 선택[+]을 유지하려면 엔터키를 누르고, 아니면 선택 번호를 입력하십시오:2 # 11버전 선택

     

     

    다시 자바 버전을 확인해보자.

    $ java -version
    openjdk version "11.0.12" 2021-07-20 LTS
    OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
    OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)
    728x90
Designed by Tistory.