728x90

m1 JDK

brew install --cask temurin17
brew install --cask temurin8
brew install --cask temurin11

Jdk 1.8 설치

  • 경로 확인
/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
  • MacOS 기본 ~.bash_profile 을 만들어 준다. 
touch ~/.bash_profile
  • 자바 홈 경로를 설정 (vim 로 .bash_profile 편집)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home

혹은 openJDK 를 설치 해도 된다. openJDK 설치서 별도의 bash_profile 설정은 하지 않아도 된다.

brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
brew cask install adoptopenjdk9
brew cask install adoptopenjdk10
brew cask install adoptopenjdk11

버전 확인

java -version
728x90

현재 설치된 JDK 버전 목록 확인

/usr/libexec/java_home -V

아래 스크립트를 복붙!

javahome_usage() {
        echo "javahome - switch to different JDK version"
        echo "Usage: javahome [-h] [-v VERSION]" 
        echo echo " -h : display usage" 
        echo " -v : specific JDK version to switch" 
        echo echo "Examples: " 
        echo "># javahome -v 1.8 : switches to JDK8" 
        echo "># javahome -v 11 : switches to JDK11"
				echo "># javahome -v 16 : switches to JDK16"
				echo "># javahome -v 17 : switches to JDK17"
        echo "># javahome : display all installed JDK and display current JDK" 
}
jhome () {
    if [ "$1" = "-h" ] ; then
        jhome_usage
    fi
    if [ "$#" -eq 0 ] ; then
        /usr/libexec/java_home -V
    fi

    if [ "$#" -eq 2 ] && [ "$1" = "-v" ] ; then
        export JAVA_HOME=`/usr/libexec/java_home $@`
        echo "Setting JAVA_HOME:" $JAVA_HOME
        echo 
        echo "Added JAVA_HOME/bin to PATH"
        PATH=$PATH:$JAVA_HOME/bin
        echo $PATH
        echo 
        java -version
    fi
}14

아래와같이 출력된다

Setting JAVA_HOME: /Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home

Added JAVA_HOME/bin to PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/bin:/Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk/Contents/Home/bin

openjdk version "14.0.2" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing)

+ Recent posts