sdkman - Multiple versions of Java JDK on Mac
Install sdkman
curl -s "https://get.sdkman.io" | bash
Verify Installation
Open a new terminal and execute
sdk version
List candidates
sdk list
List available version for a candidate
sdk list java
Install Java LTS versions
sdk install java 21.0.4-jbr
sdk install java 17.0.12-jbr
sdk install java 11.0.14.1-jbr
Set default Java version
sdk default java 21.0.4-jbr
Create alias in $HOME/.zprofile to switch jdk
echo "alias jdk_21_use='sdk default java 21.0.4-jbr'" >> $HOME/.zprofile
echo "alias jdk_17_use='sdk default java 17.0.12-jbr'" >> $HOME/.zprofile
echo "alias jdk_11_use='sdk default java 11.0.14.1-jbr'" >> $HOME/.zprofile
List current default version of a candidate
sdk current java
List currently installed versions of a java
sdk list java | grep 'installed'
Install Maven
sdk install maven
List currently installed version of maven or other candidates
sdk list maven | grep '*'
Comments
Post a Comment