This project targets Java 21 and enforces it using the Maven Toolchains plugin.
- JDK 21 installed (Microsoft, Adoptium, Oracle, etc.)
- Maven 3.9+ recommended
- Locate your JDK 21 installation path. Common examples:
C:\Program Files\Microsoft\jdk-21(Microsoft Build of OpenJDK)C:\Program Files\Eclipse Adoptium\jdk-21.*(Adoptium Temurin)C:\Program Files\Java\jdk-21(Oracle/OpenJDK)
- Copy the provided
toolchains.xmlinto your Maven user home:- Windows:
%USERPROFILE%\.m2\toolchains.xml
- Windows:
- Edit the
<jdkHome>intoolchains.xmlto match your actual JDK 21 path.
Note: The project includes
maven-toolchains-pluginrequiring JDK[21,). Maven will resolve the matching toolchain and use it for compilation.
# From repository root or project folder
mvn -f "c:\Users\sures\OneDrive\My Research\Jafima 2.0\.github\sample-java\pom.xml" clean package
mvn -f "c:\Users\sures\OneDrive\My Research\Jafima 2.0\.github\sample-java\pom.xml" testEnable the profile to require Maven to use JDK 21 via toolchains:
mvn -f "c:\Users\sures\OneDrive\My Research\Jafima 2.0\.github\sample-java\pom.xml" -DenforceToolchain=true clean packageIf your Maven version supports it, you can point to the project toolchains.xml without copying:
mvn -f "c:\Users\sures\OneDrive\My Research\Jafima 2.0\.github\sample-java\pom.xml" -DenforceToolchain=true -Dmaven.toolchains.location="c:\Users\sures\OneDrive\My Research\Jafima 2.0\.github\sample-java\toolchains.xml" clean package- "No toolchain found for type jdk" → Ensure
%USERPROFILE%\.m2\toolchains.xmlexists and<version>is21. - "Invalid JDK path" → Verify
<jdkHome>points to a validbin\java.exe. - Build still using another JDK → Confirm you don’t have a conflicting
JAVA_HOMEor PATH; Maven Toolchains should override for compilation, but global tools may still referenceJAVA_HOME.