Setup Java environment on macOS

First install SDK MAN

Then install java and gradle

sdk install java 21.0.5-amzn
sdk install gradle 8.10.2

Then create a gradle project

mkdir java-demos
cd java-demos

gradle init

Then create gradle wrapper

gradle wrapper

after then, we can use wrapper ./gradlew to build project

Run a file

./gradlew build 
./gradlew runClass -PclassName=io.petesong.leetcode.LeetCode2235

Check

./gradlew check

Then you can see the reports after checking in the folder ./build/reports

Reference

https://github.com/PeteSong/demos/tree/main/java-demos