vi ./zshrc 로 열고 아래 설정을 붙여넣기
120 export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_281.jdk/Contents/Home
121 export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/ Home
122 export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/ Home
123
124 alias java8='export JAVA_HOME=$JAVA_8_HOME; export PATH=$JAVA_HOME/bin:$PATH'
125 alias java11='export JAVA_HOME=$JAVA_11_HOME; export PATH=$JAVA_HOME/bin:$PATH'
126 alias java17='export JAVA_HOME=$JAVA_17_HOME; export PATH=$JAVA_HOME/bin:$PATH'
127
128 # 기본 JAVA_HOME 설정
129 export JAVA_HOME=$JAVA_11_HOME
130 export PATH=$JAVA_HOME/bin:$PATH
결과
// 현재 버전 확인
java -version
openjdk version "11.0.23" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-11.0.23.9.1 (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.23.9.1 (build 11.0.23+9-LTS, mixed mode)
// 17로 변경
java17
java -version
openjdk version "17.0.11" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-17.0.11.9.1 (build 17.0.11+9-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.11.9.1 (build 17.0.11+9-LTS, mixed mode, sharing)