Fix invalid source release: 21
The active compiler is older than the Java 21 source level requested by the project. Check the actual JDK and every place that sets it.

What the message means
invalid source release: 21 is usually printed by javac when a project asks it to compile at Java 21 language level but the active compiler is older and does not recognize that level. A nearby wording is release version 21 not supported. It does not mean Java 21 is unavailable in general, and it does not mean the Minecraft version is “21.” The mismatch is between the build configuration and the JDK that actually compiles the source.
Separate the Java runtime that starts the build tool from the target version. Maven or Gradle can run on one JVM and select another JDK through a toolchain. Check the environment that failed, not a java -version result from a different computer when the build runs on a remote host. In NYXO JAR, inspect the environment summary and build log to see which Java version was actually selected.
Maven settings
Open pom.xml and search for maven.compiler.release, maven.compiler.source, maven.compiler.target, and the maven-compiler-plugin configuration. Prefer one clear release setting over several conflicting values. A parent POM or profile may define the value, so checking only the first file is not enough for a multi-module build. Confirm that Maven's active JDK supports the requested level.
If you use Maven Toolchains, check the available toolchains.xml and confirm that Maven selects the intended JDK. A toolchain declaration can describe what to choose, but it does not guarantee every environment has that JDK installed or can download it. Do not place repository passwords in an uploaded POM; credentials belong in a protected environment outside the project.
Gradle settings
With modern Gradle, inspect java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } or the equivalent Kotlin DSL. Also check options.release and any plugin that modifies Java compilation. A toolchain separates the Gradle runtime from the compiler version, but the requested JDK must be available in the build environment or downloadable under its configuration.
Older projects may set sourceCompatibility and targetCompatibility in multiple files. A value of 21 in one module and a lower value in another can produce different errors depending on the task. Check the root of a multi-project build and the file belonging to the failed module. Do not change the wrapper, JDK, and Java target all at once; change the variable that explains the error.
Choose a fix that fits the target
If the source uses Java 21 features, compile with JDK 21 or a newer version that is compatible with the build tool, while checking Minecraft and platform requirements. If the code does not need recent language features and must run on an older server, an older Java target may be possible, but only if the source and dependencies do not use newer bytecode. Installing an older compiler while leaving the project set to 21 will not fix the problem. Building on a newer JDK with an older target also does not guarantee every dependency supports that target.
Check the target server before lowering the release. Minecraft 1.20.5 and newer require Java 21 to run official server software; older releases have different requirements depending on the version and platform. Do not use the Minecraft number alone as a substitute for the platform documentation. The Java and Minecraft chart gives the general mapping, and the Paper page helps identify plugin context.
A practical check sequence
- Save the complete error and the task that failed.
- Identify the JDK used inside the build process.
- Search the root and module for
release,sourceCompatibility, and toolchain settings. - Make the configuration consistent, then rebuild, cleaning old outputs if needed.
If updating Java changes the error to Unsupported class file major version 65, another tool may need an update; use the major version 65 guide. If the build completes but the server rejects the plugin, check the server's Java runtime and its startup message. Build errors and load errors are different stages.
Useful details when asking for help
Share the active JDK, Maven or Gradle version, the part of the build file that sets Java, and the name of the failed module. Remove private repository addresses and credentials. Include the Minecraft version and target platform; without them, lowering Java may seem to work while making the plugin incompatible with its server. If you built with NYXO JAR, include the first relevant error from the build log rather than only a screenshot of the final line.
Do not rely only on Java in your terminal
Your terminal may report Java 21 while a Maven or Gradle daemon uses another JDK path. A Gradle daemon can remain alive after an environment change, and Maven may point to a different installation through JAVA_HOME. Record the command that launches the build and inspect the JVM used by that process. For a remote build service, the Java installed on your computer is not evidence of the server's compiler version.
After aligning the setting, remove stale generated output if an earlier compiler result remains, then build again. Do not clear caches just because of a source-release message; the usual issue is the active JDK, not damaged cache data. In a parent POM or multi-module Gradle build, inspect every module: one may request 21 while another uses 17. Document the target Java version so the next developer does not have to infer it.
Confirm the compiler received the Java setting
A project may declare a Java toolchain while a plugin overrides compiler options, or a child module may not inherit the root setting. Run the failing task with detailed logging in your environment and look for the javac path or release value passed to the compiler. An IDE can also use a different JDK from the Gradle wrapper or Maven command. Compare the actual commands instead of assuming all tools read the same setting.
After fixing the value, run a clean build across all modules. If the message changes to a class-file major error or a Gradle startup failure, the process likely reached another stage; it does not necessarily mean the compiler setting is still wrong. Use the major version 65 guide for the new message and keep both logs for comparison.