Setting of JAVA_HOME is overwritten by mvn. /usr/bin/mvn is a script that sources /etc/java/maven.conf which overrides JAVA_HOME. If maven-openjdk11 is installed then this is Java 11, if maven-openjdk17 is installed it is Java 17 regardless of the user's setting of JAVA_HOME. This means that the compilation of a Java source file with features incompatible with the version set in /etc/java/maven.conf will fail. e.g: 1. install maven-openjdk11 3. use 'alternatives' to set java to java 17 (JAVA_HOME set to /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-1.rolling.fc35.x86_64) 4. Attempt to use maven to compile Java that has Java 17 features 5. Compilation fails If MAVEN_SKIP_RC environment variable is set then /etc/mavenrc, /etc/mavenrc and "$HOME/.mavenrc" are ignored. This will mean that JAVA_HOME is not overwritten but maven may then run with a (possible) incompatible version. (setting JAVA_HOME in "$HOME/.mavenrc" will also do this) In /usr/bin/mvn, maven is run with the java specified in JAVACMD. if [ -z "$JAVA_HOME" ] ; then JAVACMD=`which java` else JAVACMD="$JAVA_HOME/bin/java" fi It looks to me that a better solution is to set JAVACMD to specific Java version of the installed maven libraries (e.g. 11) and leave alone JAVA_HOME so that the user java files are compiled as expected.
Pull request: https://src.fedoraproject.org/rpms/maven/pull-request/31
FEDORA-2021-8d99f2be15 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2021-8d99f2be15
FEDORA-2021-8d99f2be15 has been pushed to the Fedora 36 stable repository. If problem still persists, please make note of it in this bug report.
FEDORA-2021-02d9cfd280 has been submitted as an update to Fedora 35. https://bodhi.fedoraproject.org/updates/FEDORA-2021-02d9cfd280
FEDORA-2021-02d9cfd280 has been pushed to the Fedora 35 stable repository. If problem still persists, please make note of it in this bug report.