Java sdkman maven gradle (and spring boot) - mhulse/mhulse.github.io GitHub Wiki

This works in a macOS environment:

$ curl -s "https://get.sdkman.io" | bash
$ source ~/.sdkman/bin/sdkman-init.sh
# Check available java versions:
$ sdk list java
$ sdk install java 13.0.1-open
# OR, install AdoptOpenJDK LTS (https://adoptopenjdk.net/):
$ sdk install java $(sdk list java | grep -o "11\.[0-9]*\.[0-9]*\.hs-adpt" | head -1)
$ sdk install gradle
$ sdk install maven
$ sdk install sbt

You may need to add this to your profile (.bash_profile or .zshrc if using zsh):

export JRE_HOME=$(/usr/libexec/java_home)
export JAVA_HOME=$(/usr/libexec/java_home)

Optional, if you want to use spring-boot framework:

$ sdk install springboot
$ git clone [email protected]:ieq/some-spring-project.git
$ cd some-spring-project
$ mvn spring-boot:run

Some commands/tips:

# Display project deps:
$ mvn dependency:tree
# Create built package:
$ mv package
# Remove files generated at build-time in a project’s directory:
$ mvn clean package
# Versions:
$ java -version
$ gradle -v
$ mvn --version
$ spring --version

If you use Homebrew, you might want to run:

$ brew doctor && brew update && brew upgrade && brew cleanup && brew prune && brew doctor

If you use casks:

$ brew cask outdated | xargs brew cask reinstall