Switching Between Java 21 and Java 25 per Project with update-alternatives and JAVA_HOME
Developers often need both Java 21 and Java 25, two long-term support releases, on the same machine for different projects. Switching the system default each time a repository changes quickly becomes tedious and does not explain mismatches between java -version and build tools. The guide describes a three-level model: a system-wide default, a shell or directory override, and per-build pinning. On Ubuntu 24.04, both JDKs can be installed from the Universe repository after enabling it and refreshing the package index. Each JDK lands in its own directory under /usr/lib/jvm, and update-alternatives can then select which one the system-wide default uses.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in