Look for available Java versions in the env - figure out versions of Java located at JAVA_HOME and all JAVAx_HOME env vars (actually execute java -version to check)
Figure out supported Java versions by Cassandra distribution - for Cassandra 5.1+ binary distribution the supported Java versions can be read from cassandra.in.sh and for Cassandra 5.0+ source distribution the supported Java versions can be read from build.xml. For other Cassandra versions, the supported Java versions are hardcoded in CCM
If Java version is explicitly provided - use it if it is available (see 1), warn if it is not supported by Cassandra
If JAVA_HOME is defined, use that Java distribution if it is supported by Cassandra distribution; if it is not supported, select the closest supported (see 2) and available (see 1) Java version
If JAVA_HOME is not defined, use the highest supported (see 2) and available (see 1) Java version
Also, if Java is available on the PATH, JAVA_HOME must be defined as well and both must refer to the same Java version. Fail if Java is available on the PATH and there is no JAVA_HOME or if JAVA_HOME refers a different Java version than Java defined on the PATH.
Also,
Added --jvm-version option to the cluster and node start commands.
Fixed one problem with Java selection for tools run on the upgraded node
The logic works as follows:
Look for available Java versions in the env - figure out versions of Java located at
JAVA_HOME
and allJAVAx_HOME
env vars (actually executejava -version
to check)Figure out supported Java versions by Cassandra distribution - for Cassandra 5.1+ binary distribution the supported Java versions can be read from
cassandra.in.sh
and for Cassandra 5.0+ source distribution the supported Java versions can be read frombuild.xml
. For other Cassandra versions, the supported Java versions are hardcoded in CCMIf Java version is explicitly provided - use it if it is available (see 1), warn if it is not supported by Cassandra
If
JAVA_HOME
is defined, use that Java distribution if it is supported by Cassandra distribution; if it is not supported, select the closest supported (see 2) and available (see 1) Java versionIf
JAVA_HOME
is not defined, use the highest supported (see 2) and available (see 1) Java versionAlso, if Java is available on the
PATH
,JAVA_HOME
must be defined as well and both must refer to the same Java version. Fail if Java is available on thePATH
and there is noJAVA_HOME
or ifJAVA_HOME
refers a different Java version than Java defined on thePATH
.Also,
--jvm-version
option to the cluster and node start commands.