Skip to main content

JVM

JVM-related helpers shipped by this repo — JDK switching and Maven OpenRewrite recipe runners.

Tip 23.1: JDK Switching​

jdk flips JAVA_HOME (and PATH) between Homebrew-installed OpenJDKs.

jdk 21 # switch to OpenJDK 21
jdk 25 # switch to OpenJDK 25
jdk # show currently active JDK and available versions
echo $JAVA_HOME # see where it pointed JAVA_HOME

On macOS JAVA_HOME lands on the nested libexec/openjdk.jdk/Contents/Home, not the Homebrew keg root. The keg root carries only bin/ symlinks, so anything that validates a real JDK layout — IntelliJ's Gradle JVM — rejects it even though java runs fine from it. Linux has no such nesting and gets the prefix as-is.

Works with any Homebrew OpenJDK: an openjdk@N formula, or plain openjdk for the latest release. New shells start on the newest installed LTS. From source/10_java.sh.

Tip 23.2: Maven OpenRewrite Recipes​

Run OpenRewrite refactoring recipes against the current Maven project. Useful for big migrations.

mvn-check-tests # run the test suite, summarise pass/fail counts
mvn-rewrite-junit # migrate JUnit 4 → JUnit 5
mvn-rewrite-asserts # migrate Hamcrest/JUnit asserts → AssertJ
mvn-rewrite-runwith # migrate @RunWith → @ExtendWith (JUnit 5)

These are thin wrappers around the corresponding mvn org.openrewrite.maven:rewrite-maven-plugin:run invocations, so the Maven project must have OpenRewrite available. From source/45_maven.sh.