JDK 정리

Homebrew-cask-versions

참고:

homebrew-cask

homebrew-cask-versions

brew tap homebrew/cask-versions
# 설치된 파일들 확인
brew list --cask




JDK 종류

OracleJDK

brew install --cask oracle-java

Temurin

brew install --cask temurin

Amazon Corretto

brew install --cask corretto

설치된 jdk 확인

ls /Library/Java/JavaVirtualMachines

주의




JDK 환경변수 설정

참고: java_home and JAVA_HOME on macOS

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk/Contents/Home
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

$JAVA_HOMEjava_home 관련 명령어들

JDK 버전 확인

# 설치된 JDK들 전체 확인
/usr/libexec/java_home -V

# 특정 JDK 버전 확인(as if JAVA_VERSION had been set in the environment)
/usr/libexec/java_home -v 1.x

# default JDK 버전 확인
/usr/libexec/java_home

java_home으로 $JAVA_HOME 쉽게 설정하기

# 특정 버전으로
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`

# default로
export JAVA_HOME=`/usr/libexec/java_home`




Uninstall JDK

# remove jdk installed directory
sudo rm -rf /Library/Java/JavaVirtualMachines/[설치된 버전]
# remove java control panel
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
# remove applet plugins
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/
# remove application support
sudo rm -rf ~/Library/Application\ Support/Java
# remove the java updater list
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
# remove the java helper tool
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist

참고: How To Install / Uninstall Multiple Java Versions In Mac OS By Home Brew Or Manually